Python: Need Help | Sololearn: Learn to code for FREE!
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

4th Sep 2023, 4:39 AM
Xephryx
Xephryx - avatar
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.
4th Sep 2023, 1:48 PM
Wong Hei Ming
Wong Hei Ming - avatar
+ 1
What fix you need about?
4th Sep 2023, 9:58 AM
Jayakrishna 🇮🇳