0

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
3
  • 2
    while bot_points < 3 and your_points < 3 maybe? Commented Oct 8, 2021 at 20:19
  • A good habit to get into is to learn how to use print debugging. If you had displayed the score at the end of every round you would have seen that the variables were both, in fact, incrementing properly, which would've probably very quickly helped you realize the problem was in your while loop condition. Commented Oct 8, 2021 at 20:21
  • 2
    I'd recommend also cutting down the draw conditions to if bot_choice == user_choice. Commented Oct 8, 2021 at 20:23

1 Answer 1

6

Two issues:

  1. You test for <= 3, so it won't end until someone wins four times
  2. 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:
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.