I have a tkinter button set up for sending a string to an empty list for comparison between a random computer choice of another string. Everything works accordingly, except that the following code for what to do with previously empty list executes before I am able to click the tkinter button. I know this is a weird way of programming a Rock, Paper, Scissors game. What's happening is when the "rock" button is clicked, the string "rock" is sent to an empty list for storing. The computer then picks one of three strings rock, paper, and scissors. That string is put into the other empty list for storing and immediately after to be compared with the first stored string from tkinter button. Which will give me the ability to determine who won or if it's a draw.
# Buttons for user to choose (Rock,Paper,Scissors).
button = Button(root, text="Rock", command=lambda: button_press.append("Rock"))
button.pack()
button_2 = Button(root, text="Paper", command=lambda: print("Paper"))
button_2.pack()
button_3 = Button(root, text="Scissors", command=lambda: print("Scissors"))
button_3.pack()
# Empty list for button value to be placed and compared with computers random.choice
button_press = []
comp_press = []
# Computer picks between the three options (Rock, Paper, Scissors)
rps = ["Rock"]
comp_pick = random.choice(rps)
comp_press.append(comp_pick)
if button_press == comp_press:
print("Draw!")
else:
print("Nothing")