dimanche 4 septembre 2016

If statements not working in spock lizard paper scissors and rock. (PYTHON)

Just a noob python programmer here making a Spock, lizard, rock etc... code, just wondering why my if, elif and else statements aren't working. It seems like the python doesn't even know its there. Any tips and how to be more efficient with my coding would be greatly appreciated. Sorry for the horrible variable names.

while max_attempts != 0:
    comp_list = ["Rock", "Paper", "Scissor", "Lizard", "Spock"]
    comp_choice = comp_list[random.randint(0, 4)]
    player_choice = making_user_choice_valid("Please choose one of the following choices..." '\n'
                                        "Rock" '\n'
                                        "Paper" '\n'
                                        "Scissor" '\n'
                                        "Lizard " '\n'
                                        "or Spock")

    if player_choice == comp_choice:
        print("It's a draw!")
        print("Computer picked, ", comp_choice, "and you picked", player_choice)
        draw = draw + 1
    elif player_choice == "Lizard":
        if comp_choice == "Paper" or comp_choice == "Spock":
            win = win + 1
            print("You win!")
            print("Computer picked, ", comp_choice, "and you picked", player_choice)
    elif player_choice == "Spock":
        if comp_choice == "Rock" or comp_choice == "Scissors":
            win = win + 1
            print("You win!")
            print("Computer picked, ", comp_choice, "and you picked", player_choice)
    elif player_choice == "Scissors":
        if comp_choice == "Lizard" or comp_choice == "Paper":
            win = win + 1
            print("You win!")
            print("Computer picked, ", comp_choice, "and you picked", player_choice)
    elif player_choice == "Paper":
        if comp_choice == "Spock" or comp_choice == "Rock":
            win = win + 1
            print("You win!")
            print("Computer picked, ", comp_choice, "and you picked", player_choice)
    elif player_choice == "Rock":
        if comp_choice == "Scissors" or comp_choice == "Lizard":
            win = win + 1
            print("You win!")
            print("Computer picked, ", comp_choice, "and you picked", player_choice)
    else:
        lost = lost + 1
        print("You've lost!")
        print("Computer picked, ", comp_choice, "and you picked", player_choice)
    max_attempts -= 1


retry = input("Would you like another try?")
if "No" in retry or "NO" in retry or "no" in retry:
    print("Goodbye!")
    break
else:
    print("Initializing the game....")

Aucun commentaire:

Enregistrer un commentaire