mardi 1 septembre 2020

how can I solve str' object does not support item assignmen?

I'm trying to solve the Monty Hall problem in python.

First, I made three buttons using TKinter and the built-in random module. I also assigned objects to each button.

[button,button1,button2]=random.shuffle(['goat,'goat','car'])

Then I defined the function that happen upon clicking the buttons.

for example,

def asdf():
    button['image']=goat image

That's when I get the error: str object does not support item assignment.

I understandd that 'goat' and 'car' are strings so I can't assign to them. But how can I make the button show my images?




Aucun commentaire:

Enregistrer un commentaire