I need help finishing my python rock paper scissors code, where it asks the user "rock, paper, scissors", the user types either option (repeatedly asks until its one of the three), and for a random option from the code to select also rock paper scissors. The end result would be you winning, code winning, or a tie.My code:import randomOPTIONS = ("ROCK", "PAPER", "SCISSOR") def getInput(): """ Function getInput() will receive and validate user input to be the string ROCK, PAPER, or SCISSOR. Input must be spelled correctly and in all capital letters. Function will return the validated input @return user input as ROCK, PAPER, OR SCISSOR """ #need help here def checkWinner(user, computer): """ Function checkWinner will accept 2 string parameters that must be unique values of ROCK, PAPER, or SCISSOR. Functions should return true if the string in parameter user beats the string in parameter computer in a game of rock paper, scissor and false otherwise @param user: contains string ROCK, PAPER or SCISSOR @param computer: contains string ROCK, PAPER or SCISSOR, but cannot be the same as user @return: True is user beats computer false othewise """ #need help here def main(): #Code here is good, no change needed. print("Welcome to Rock, Paper, and Scissors") user = getInput() computer = random.choice(OPTIONS) print(f"You chose: {user}") print(f"I chose: {computer}") while user == computer: print("Tie game, play again") user = getInput() computer = random.choice(OPTIONS) print(f"You chose: {user}") print(f"I chose: {computer}") winner = checkWinner(user, computer) if winner: print("You Won!") else: print("I Won!") main()
I need help finishing my python rock paper scissors code, where it asks the user "rock, paper, scissors", the user types either option (repeatedly asks until its one of the three), and for a random option from the code to select also rock paper scissors. The end result would be you winning, code winning, or a tie.
My code:
import random
OPTIONS = ("ROCK", "PAPER", "SCISSOR")
def getInput():
"""
Function getInput() will receive and validate user input to be
the string ROCK, PAPER, or SCISSOR. Input must be spelled correctly
and in all capital letters. Function will return the validated input
@return user input as ROCK, PAPER, OR SCISSOR
"""
#need help here
def checkWinner(user, computer):
"""
Function checkWinner will accept 2 string parameters that must be unique
values of ROCK, PAPER, or SCISSOR. Functions should return true if the
string in parameter user beats the string in parameter computer in a game
of rock paper, scissor and false otherwise
@param user: contains string ROCK, PAPER or SCISSOR
@param computer: contains string ROCK, PAPER or SCISSOR, but cannot
be the same as user
@return: True is user beats computer false othewise
"""
#need help here
def main():
#Code here is good, no change needed.
print("Welcome to Rock, Paper, and Scissors")
user = getInput()
computer = random.choice(OPTIONS)
print(f"You chose: {user}")
print(f"I chose: {computer}")
while user == computer:
print("Tie game, play again")
user = getInput()
computer = random.choice(OPTIONS)
print(f"You chose: {user}")
print(f"I chose: {computer}")
winner = checkWinner(user, computer)
if winner:
print("You Won!")
else:
print("I Won!")
main()

Step by step
Solved in 2 steps








