Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

# RocksPapersScissors #449

Open
PavanCheruvupally opened this issue Nov 27, 2023 · 1 comment
Open

# RocksPapersScissors #449

PavanCheruvupally opened this issue Nov 27, 2023 · 1 comment

Comments

@PavanCheruvupally
Copy link

          # 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)

@Robot403
Copy link

Robot403 commented Dec 7, 2023

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
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants