New course! Every coder should learn Generative AI!
Try a free lesson+ 1
Python: Need Help
I'm a beginner and I've created my first game which seems to almost work but not quite sure what is missing.. https://code.sololearn.com/c4eKCzZfGe26/?ref=app
2 Answers
+ 3
Indeed it is almost works, except computer always pick a same choice.
The reason is quite simple. Variable random doesn’t change inside the loop.
It is declared outside the loop and always be 0, 1 or 2 and never change.
Change the line
computer_pick=choices[random]
to
computer_pick=choices[random.randint(0,2)]
and it should fix it.
Oh. And don't forget to comment out random which is outside the loop.
+ 1
What fix you need about?