i have began python this year and am creating a simple Rock Paper Scissors game with integrated score keeper. The program is causing an undesirable loop (repeating the main menu portion.) i am 98% sure this is caused by an improper indentation somewhere in the loop but i am just stumped. run the code and see if you can find my mistake. thank you!!!
import random as rand
computer_score = 0
user_score = 0
print("""
==========================
Rock, Paper, or Scissors?
==========================
""")
# while loop to perform finite loop as long as specific perameters are met
while True:
option = ["Rock", "Paper", "Scissors"]
a = rand.choice(option)
user_input = input("""Choose one:
1) Rock
2) Paper
3) Scissors
press 'Q' to quit game
Enter your option: """)
# line 28,29) to make sure user_input string is a digit and to convert string to an integer
# line 30) since indexing always starts at 0, if user inputs "rock (1)"...
# [user_input - 1] will make sure "Rock" is selected in list(option[0])
# line 30,31) if user_input is the same as random choice (a): user/computer_score will not change
if user_input.isdigit == True:
user_input = int(user_input)
if option[user_input - 1] == a:
computer_score, user_score = computer_score, user_score
print("its a tie!")
print("computer: ", a, "user: ", user_input)
print("computer score: ", computer_score,
" user score: ", user_score)
print("\n")
# line 39,40,41)if user_input is rock and random choice (a) is paper: computer_score will add 1
elif option[user_input - 1] == "Rock":
if a == "Paper":
computer_score = computer_score + 1
print("computer wins!")
print("computer: ", a, "user: ", user_input)
print("computer score: ", computer_score,
" user score: ", user_score)
print("\n")
elif a == "Scissors":
user_score = user_score + 1
print("you win!")
print("computer: ", a, "user: ", user_input)
print("computer score: ", computer_score,
" user score: ", user_score)
print("\n")
elif option[user_input - 1] == "Paper":
if a == "Rock":
user_score = user_score + 1
print("you win!")
print("computer: ", a, "user: ", user_input)
print("computer scoore: ", computer_score,
" user score: ", user_score)
print("\n")
elif a == "Scissors":
computer_score = computer_score + 1
print("computer wins")
print("computer: ", a, "user: ", user_input)
print("computer_score: ", computer_score,
" user score: ", user_score)
print("\n")
elif option[user_input - 1] == "Scissors":
if a == "Rock":
computer_score = computer_score + 1
print("computer wins")
print("computer: ", a, "user: ", user_input)
print("computer score: ", computer_score,
" user score: ", user_score)
print("\n")
elif a == "Paper":
user_score = user_score + 1
print("You win!")
print("computer: ", a, "user: ", user_input)
print("computer score: ", computer_score,
" user score: ", user_score)
print("\n")
elif user_input.isdigit() == False:
if str(user_input) == "q" or "Q":
print("final score: \n")
print("computer score: ", computer_score,
" user score: ", user_score)
else:
print("invalid input")