It can be difficult to specifically strip code from submitted text in a text box...
Well... not 'difficult' but cumbersome :)
One thing I might recommend would be that you look into Regular Expressions as, using that, you can specify strings to be excluded/filtered from submitted text (such as URLs and script openers). The only drawback with the RegEx method is that you kind of have to be specific about the things you are excluding (ie: if you don't specify it, it won't be excluded).
Another thing you can combine with RegEx filtering is SubString segments (to catch everything between the opening and closing braces of an HTML or script tag for example). Simply grab everything from the first IndexOf to the following closing brace and snip it out. This can add a bit of heft to your coding however and also means a lot more room for error if not coded correctly.
Hope this helps :) Please remember to mark the thread solved once your issue is resolved.
Edit: One thing I forgot to mention is that RegEx is case sensitive so you either need to utilize separate RegEx values for both capital and lower case or convert the input entirely to upper/lower prior to utilizing RegEx on it (which can be detrimental to the valid input from the user).
root = tkinter.Tk()
buttons=[i for i in range(10)]
#If specific button is pressed, output "YES"
for num in buttons: