Rps.py

I made a rock paper scissors game on python today. It is a simple random loop of basic inputs and responses. Here is the code.

import random

options = ("rock", "paper", "scissors")
running = True

while running:

    player = input("Enter a choice >")
    computer = random.choice(options)
    
    while player != options:
        print("bad boy")
        player = input("Enter a choice >")

    print(f"Player: {player}")
    print(f"Computer: {computer}")

    if player == computer:
        print("It's a tie!")
    elif player == "rock" and computer == "scissors":
        print("You win!")
    elif player == "paper" and computer == "rock":
        print("You win!")
    elif player == "scissors" and computer == "paper":
        print("You win!")
    else:
        print("You lose!")

    if not input("Play again? (y/n): ").lower() == "y":
        running = False

print("Thanks for playing!")


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *