import random
#1 = Rock, 2 = Paper, 3 = Scissors
random_number = random.randint(1,3)
try:
input = int(input("1 for rock, 2 for paper, 3 for scissors: "))
except ValueError:
print("You didn't enter a number. You lose.")
if input == random_number:
if input == 1:
input = "Rock"
elif input == 2:
input = "Paper"
else:
input = "Scissors"
if random_number == 1:
random_number = "Rock"
elif random_number == 2:
random_number = "Paper"
else:
random_number = "Scissors"
print(f"You chose {input} and the computer chose {random_number}. You Tie.")
elif (input==1 and random_number==2) or (input==2 and random_number==3) or (input==3 and random_number==1):
if input == 1:
input = "Rock"
elif input == 2:
input = "Paper"
else:
input = "Scissors"
if random_number == 1:
random_number = "Rock"
elif random_number == 2:
random_number = "Paper"
else:
random_number = "Scissors"
print(f"You chose {input} and the computer chose {random_number}. You Lose.")
elif (input==1 and random_number==3) or (input==2 and random_number==1) or (input==3 and random_number==2):
if input == 1:
input = "Rock"
elif input == 2:
input = "Paper"
else:
input = "Scissors"
if random_number == 1:
random_number = "Rock"
elif random_number == 2:
random_number = "Paper"
else:
random_number = "Scissors"
print(f"You chose {input} and the computer chose {random_number}. You Win.")
else:
if type(input) is int:
print("You chose an invalid number. You Lose.")
This code should play rock paper scissorplays the "Rock, Paper, Scissors" game against the user. I was wondering how exactly should I handle my constantrepeated nesting. I am looking for more organized code.