We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Solution on Replit had errors. I made some changes:
import random
def rpsPlay(player1, player2): """ input: player1 and player2 should each be 'rock', 'paper', or 'scissors' output: the outcome of the game """
if player1 == player2: print("It's a tie!")
elif player1 == "scissors": if player2 == "rock": print ("Player 2 won!") else: print("Player 1 won!")
elif player1 == "rock": if player2 == "scissors": print ("Player 1 won!") else: print("Player 2 won!")
else: if player2 == "scissors": print ("Player 2 won!") else: print("Player 1 won!")
rps = ['rock', 'paper', 'scissors']
def choose_rps(): "output: randomly returns rock, paper, or scissors" r = random.randint(0,2) print(r) return rps[r]
def play_again(): "output: 1 or 0 for play again or not" r = random.randint(0,1) return r
play = True
print("Welcome to Rock, Paper, Scissors!") print("------") while play == True: player1 = choose_rps() player2 = choose_rps() print(f"Player 1 chose {player1}") print(f"Player 2 chose {player2}\n") rpsPlay(player1, player2) play = play_again() print("------")
print("Thank you for playing!")
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Solution on Replit had errors. I made some changes:
import random
rps function
def rpsPlay(player1, player2):
"""
input: player1 and player2 should each be 'rock', 'paper', or 'scissors'
output: the outcome of the game
"""
--game logic--
tie
if player1 == player2:
print("It's a tie!")
player1 = scissors
elif player1 == "scissors":
if player2 == "rock":
print ("Player 2 won!")
else:
print("Player 1 won!")
player1 = rock
elif player1 == "rock":
if player2 == "scissors":
print ("Player 1 won!")
else:
print("Player 2 won!")
player1 = paper
else:
if player2 == "scissors":
print ("Player 2 won!")
else:
print("Player 1 won!")
rps = ['rock', 'paper', 'scissors']
def choose_rps():
"output: randomly returns rock, paper, or scissors"
r = random.randint(0,2)
print(r)
return rps[r]
def play_again():
"output: 1 or 0 for play again or not"
r = random.randint(0,1)
return r
play = True
print("Welcome to Rock, Paper, Scissors!")
print("------")
while play == True:
player1 = choose_rps()
player2 = choose_rps()
print(f"Player 1 chose {player1}")
print(f"Player 2 chose {player2}\n")
rpsPlay(player1, player2)
play = play_again()
print("------")
print("Thank you for playing!")
The text was updated successfully, but these errors were encountered: