Skip to content

# RocksPapersScissors #449

Open
Open

Description

@PavanCheruvupally
          # RocksPapersScissors

“Rock paper scissors” is a simple and interesting game. Many of us used to play it in a school to resolve disputes or just to spend some time.

RULES: The rules are very simple and probably you remember them from your childhood:

-> If you choose Rock, you will win against Scissors but lose against Paper.

-> If you choose Scissors, you will win against Paper but lose against Rock.

-> If you choose Paper, you will win against Rock but lose against Scissors.

Originally posted by @PavanCheruvupally in #448 (review)

Activity

  1. Robot403 commented on Dec 7, 2023

    @Robot403

    import random

    game = True

    score = 0

    valid_inputs = ["rock", "paper", "scissors"]

    print("Welcome to Rock. Paper, Scissors. Let's play best 2 of 3")

    while game is True:
    while -2 < score < 2:
    print("The score is ", score)
    player_choice = input("Choose: Rock, Paper, Scissors: ").lower()
    if player_choice in valid_inputs:
    computer_choice = valid_inputs[random.randint(0, 2)]
    print("The computer chose " + computer_choice + ".")
    if player_choice == computer_choice:
    print("Tie! Try again.")
    else:
    if computer_choice == "scissors":
    if player_choice == "rock":
    print("The computer got you!")
    score -= 1
    else:
    print("You got the computer!")
    score += 1
    elif computer_choice == "rock":
    if player_choice == "paper":
    print("The computer got you!")
    score -= 1
    else:
    print("You got the computer!")
    score += 1
    elif computer_choice == "paper":
    if player_choice == "scissors":
    print("The computer got you!")
    score -= 1
    else:
    print("You got the computer!")
    score += 1

        else:
            print("Invalid input, Please try again.")
    else:
        print("Game over!")
        if score == 2:
            print("You win!")
        else:
            print("You lose!")
        game = False
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions