▲ 19 r/learnpython
Why is this code skipping the if/elif conditions?
Before anyone says anything, I did already Google and search Reddit for help.
Here's my code:
import random
rps = [0, 1, 2]
cpu = random.choice(rps)
user = input("Rock, Paper, or Scissors? 0 for rock, 1 for paper, or 2 for scissors: ")
if cpu == user:
print ("Draw")
elif cpu == 2 and user == 1:
print ("You LOSE")
elif cpu == 2 and user == 0:
print ("You WIN")
elif cpu == 1 and user == 0:
print ("You LOSE")
elif cpu == 1 and user == 2:
print ("You WIN")
elif cpu == 0 and user == 2:
print ("You LOSE")
elif cpu == 0 and user == 1:
print ("You WIN")
else:
print ("Invalid input")
No matter what number I put in I always get the "else" result. Why is that?
u/MakiiZushii — 20 hours ago