Since Trim only removes from the beginning and end, the whitespace character at the end doesn't match anything in your char array so it's done trimming. If you are trying to remove characters from the string, then you need to use the Remove method.
root = tkinter.Tk()
buttons=[i for i in range(10)]
#If specific button is pressed, output "YES"
for num in buttons: