Use fflush(stdin) before scanf for again as charley bones said. The loop doesn't work because as you press enter('\n') the '\n' is copied onto the variable again. You can also use flushall() before the scanf() for again.
root = tkinter.Tk()
buttons=[i for i in range(10)]
#If specific button is pressed, output "YES"
for num in buttons: