I have tried many times to debug this but it keeps giving me the else statement output. I do not see where I went wrong. I am trying to get the game to work, I feel that the error lies in my if/elif/else statement.
import random
rock = '''
_______
---' ____)
(_____)
(_____)
(____)
---.__(___)
'''
paper = '''
_______
---' ____)____
______)
_______)
_______)
---.__________)
'''
scissors = '''
_______
---' ____)____
______)
__________)
(____)
---.__(___)
'''
#Write your code below this line đ
x = input("What do you choose? Type 0 for rock, 1 for Paper or 2 for Scissors\n")
options = [rock, paper, scissors]
print(options[int(x)])
print("Computer chose:")
y = random.randint(0, 2)
z = int(y)
print(options[z])
#For Rock
if x == 0 and z == 2:
print("You win!")
elif x == 0 and z == 0:
print("It is a draw!")
elif x == 0 and z == 1:
print("You lose.")
#For Paper
elif x == 1 and z == 0:
print("You win!")
elif x == 1 and z == 1:
print("It is a draw!")
elif x == 1 and z == 2:
print("You lose.")
#For Scissors
elif x == 2 and z == 1:
print("You win!")
elif x == 2 and z == 2:
print("It is a draw!")
else:
print(z)
Aucun commentaire:
Enregistrer un commentaire