dimanche 7 mai 2017

What is wrong with my rock, paper, scissors code?

Using python, I have to create a rock paper scissors game for school that the user plays against the computer. The computer's choice also has to be random. When i try to run this code its says that there is a syntax error but not where it is. Can anyone help?

    import random

print("Welcome to rock paper scissors.")

player = False

while player == False:
    print(" ")
    print("Press 1 for Rock")
    print("Press 2 for Paper")
    print("Press 3 for Scissors")

    User = int(input("Rock, Paper or Scissors?"))
    Com = random.randrange(1,3)

    if (User == 1) and (Com == 1):
        player = False
    print("Its a draw!")

    elif (User == 2) and (Com == 1):
        player = True
    print("You win!")

    elif (User == 3) and (Com == 1):
        player = True
    print("You lose!")

    elif (User == 1) and (Com == 2):
        player = True
    print("You lose!")

    elif (User == 2) and (Com == 2):
        player = False
    print("Its a draw!")

    elif (User == 3) and (Com == 2):
        player = True
    print("You win!")

    elif (User == 1) and (Com == 3):
        player = True
    print("You win!")

    elif (User == 2) and (Com == 3):
        player = True
    print("You lose!")

    elif (User == 3) and (Com == 3):
        player = False
    print("Its a draw! You both entered scissors.")

    else:
        print("Make sure to enter a number from 1 - 3")




Aucun commentaire:

Enregistrer un commentaire