could you tell me why my program doesnt increment "bot_points = 0" "your_points = 0" to stop the while loop when some of these values reach 3
import random
rock_paper_scissors = ["ROCK", "PAPER", "SCISSORS"]
bot_points = 0
your_points = 0
while bot_points <= 3 or your_points <= 3:
user_choice = input('type "rock", "paper" or "scissors": ').upper()
bot_choice = random.choice(rock_paper_scissors)
if bot_choice == "ROCK" and user_choice == "ROCK":
print("Draw")
elif bot_choice == "ROCK" and user_choice == "PAPER":
print("You win")
your_points = your_points 1
elif bot_choice == "PAPER" and user_choice == "PAPER":
print("Draw")
elif bot_choice == "PAPER" and user_choice == "SCISSORS":
print("You win")
your_points= your_points 1
elif bot_choice == "PAPER" and user_choice == "ROCK":
print("You lose")
bot_points = bot_points 1
elif bot_choice == "SCISSORS" and user_choice == "PAPER":
print("You lose")
bot_points = bot_points 1
elif bot_choice == "SCISSORS" and user_choice == "ROCK":
print("You win")
your_points = your_points 1
elif bot_choice == "SCISSORS" and user_choice == "SCISSORS":
print("Draw")
elif bot_choice == "ROCK" and user_choice == "SCISSORS":
print("You lose")
bot_points = bot_points 1
CodePudding user response:
Two issues:
- You test for
<= 3
, so it won't end until someone wins four times - You test
bot_points <= 3 or your_points <= 3
, so it won't end until both players win at least four times;and
would end when either reaches the threshold
If you want to end when either player wins three times, change the test to:
while bot_points < 3 and your_points < 3: