I am making a Rock Paper Scissors game for a school project. I can't figure out how to make the buttons call the same function with different arguments. Here is my relevant code:
def choose(what):
Computer = random.randrange(1,3)
if what == "r":
if Computer == 2:
loose
else:
win
elif what == "p":
if Computer == 3:
loose
else:
win
elif what == "s":
if Computer == 1:
loose
else:
win
else:
msg.showerror("Invalid Option", "What you choose is invalid. Choose something else.")
Button(root, text="Rock", command=choose("r")).pack()
Button(root, text="Paper", command=choose("p")).pack()
Button(root, text="Scissors", command=choose("s")).pack()
This does not result in an error, but also doesn't call it.