Skip to content
Advertisement

Fixing a while-loop to only run once

I am trying to create a simple Rock, Paper, Scissors game to practice some basic Python skills. I created the code below to take user input and create a simple point-based game. However, when I ran the code, the loop ran infinitely, printing the output message until I force stopped it. How can I alter my code so the while-loop only runs once per user input?

code:

JavaScript

Advertisement

Answer

the problem is that unless you loose on your first round you keep winning for ever because none of the input values changed. all you have to do is move your input() and the computers random selection into the loop like this

JavaScript
Advertisement