Here is my code. I'm trying to make a rock, paper, scissors game for a school project.
import random choices = ["Rock", "Paper", "Scissors"] player_choice = input("Rock, Paper, Scissors?").lower() while player_choice not in choices: player_choice = input("Rock, Paper, Scissors?").lower() computer_choice = random.randint(0,2) if computer_choice == 0: cpu_choice = choices[0] elif computer_choice == 1: cpu_choice = choices[1] elif computer_choice == 2: cpu_choice = choices[2] print() print("You play:", player_choice) print("The computer plays:", cpu_choice) print() if player_choice == "Rock": if cpu_choice == choices[0]: print("Draw") elif cpu_choice == choices[1]: print("You Lose :((") else: print("You win!! :>>") if player_choice == "Paper": if cpu_choice == choices[0]: print("You win!! :>>") elif cpu_choice == choices[1]: print("Draw") else: print("You Lose :((") if player_choice == "Scissors": if cpu_choice == choices[0]: print("You Lose :((") elif cpu_choice == choices[1]: print("You Win!!! :>>") else: print("Draw") The result you get is: Rock, Paper, Scissors?rock Rock, Paper, Scissors?Rock Rock, Paper, Scissors?Rock
and it keeps going like this even though rock is part of choices. This also happens if I input scissors in lowercase or paper.
https://stackoverflow.com/questions/66056827/how-to-allow-an-input-to-be-in-lowercase-and-uppercase-in-python February 05, 2021 at 10:38AM
没有评论:
发表评论