Read the API for String. There is a method there, inherited from Object, with the same name as the symbol used in many comparisons. Use that method. (And, yes, I am being purposely obscure.)
Edit: Aaarrgh, and another newb has already given code. Do not give out easy answers without the poster showing some initiative. I can almost guarntee this is some sort of homework/assignment question, and he should do those himself, not just be given an answer.
root = tkinter.Tk()
buttons=[i for i in range(10)]
#If specific button is pressed, output "YES"
for num in buttons: