mardi 9 juillet 2019

My If Statements in Python are not working

I am new to python and I am writing a program to play Rock, Paper, Scissor. When I start to do the if else statements to compare outputs from user and the computer, my program just completely skips the if-else statements. Not sure what's going on with it.

user = input("Please enter Rock, Paper, Scissor: ")
while user not in ("Rock", "Paper", "Scissor"):
      print("Try again")
      user = input("Please enter Rock, Paper, Scissor: ")


if user == "Rock":
   print("Your Choice is Rock")
elif user == "Scissor":
   print("Your Choice is Scissor")
elif user == "Paper":
   print("Your Choice is Paper")


import random
AI=["Rock", "Paper", "Scissor"]
b=random.randint(0,2)
print("The computer choice is " + AI[b])

if user == b:
   print("Tie")
elif user == "Rock":
   if b == "Scissor":
      print("Rock Beats Scissor")

It goes through all of the code expect the last if-else statement. It just finishes the program after the computer chooses what to use.

Aucun commentaire:

Enregistrer un commentaire