dimanche 10 octobre 2021

Why is my print statement not displaying in my Python rock paper scissors game?

I am to coding -- especially in Python. I have coded a basic rock, paper, scissors game but my print statement -- to display winner / loser isn't working. Can anybody help??

import random
print("Hello! Welcome to Rock//Paper//Scissors -- let's play!")
print("Starting game...")


def game():
    while True:

        player_choice = str(input("What's your choice? Rock, Paper, Scissors! ").lower)
        actions = ["rock", "paper", "scissors"]
        computer_choice = str(random.choice(actions))

        if player_choice == computer_choice:
            print(f"We chose the {player_choice}! I guess it's a tie!")
            continue
        elif player_choice == "rock":
            if computer_choice == "scissors":
                print("Rock breaks scissors... I guess you win.")
            else:
                print("Paper covers and kills rock! Haha I win!")
        elif player_choice == "paper":
            if computer_choice == "rock":
                print("Paper beats rock. I guess you win this time :/")
            else:
                print("My strong scissors cuts up your thin paper! I win!!")
        elif player_choice == "scissors":
            if computer_choice == "paper":
                print("For some reason your scissors beat my paper! Unfortunately, you win this time :(")
            else:
                print("My rock smashes up your scissors! I win and you lose :D")

                replay = input("Play again? (y/n): ")
                if replay.lower() != "y":
                    break


game()



Aucun commentaire:

Enregistrer un commentaire