I'm trying to create a rock paper scissors text game (as part of my journey to learn coding!). However, I want the user to be able to input 'rock', 'paper', and 'scissors' rather than 0, 1, 2 etc. I keep hitting a stumbling block in correctly returning/printing the result - specifically the draw result. Now I know why this is the case; because 0, 1, 2 does not equal 'rock', 'paper', 'scissors'. What's the best way around this?
import random
rock = '''
_______
---' ____)
(_____)
(_____)
(____)
---.__(___)
'''
paper = '''
_______
---' ____)____
______)
_______)
_______)
---.__________)
'''
scissors = '''
_______
---' ____)____
______)
__________)
(____)
---.__(___)
'''
computer = [scissors, rock, paper]
print("Welcome to Rock, Paper, Scissors!")
user_input = input("Will you choose Scissors, Paper, or Rock?\n").lower()
if user_input == "rock":
print(rock)
elif user_input == "paper":
print(paper)
elif user_input == "scissors":
print(scissors)
computer_choices = random.randint(0, 2)
print("Computer chose: ")
print(computer[computer_choices])
if user_input == computer_choices:
print ("It's a draw!")
elif user_input == "rock":
if computer_choices == 2:
print ("You lose!")
else:
print("You win!")
elif user_input == "paper":
if computer_choices == 0:
print("You lose!")
else:
print("You win!")
elif user_input == "scissors":
if computer_choices == 1:
print("You lose!")
else:
print("You win!")
That's my code above - how can I learn to fix this?
Thanks in advance all!!