I agree with radow here. There's nothing syntactically wrong with your rewrite conditions or rule. The HTTP 500 error you're receiving is likely because mod_rewrite is not enabled. Do you have any other configuration details in your .htaccess file that may be causing the 500 error? If not, I would change your rewrite body to this:
root = tkinter.Tk()
buttons=[i for i in range(10)]
#If specific button is pressed, output "YES"
for num in buttons: