Question: Convert the user input strings to lower case so that you only have to check lower case in your test. Hint: look at the lower()

  1. Convert the user input strings to lower case so that you only have to check lower case in your test. Hint: look at the lower() function in Python.
  2. Create a loop for each input that does the following:
    • Check the value of the input
    • If the value is not correct, alert the user
    • Give the user a total of three chances to get it right
    • If they don't get it right in three tries, use sys.exit to exit the code and give them a message that they exceeded their allowable number of tries

import sys

# Get User input player1 = input('Enter Value for Player 1: ') if (player1 != 'rock' and player1 != 'paper' and player1 != 'scissors'): print('Player1 input incorrect') sys.exit('Input Error') player2 = input('Enter Value for Player 2: ') if (player2 != 'rock' and player2 != 'paper' and player2 != 'scissors'): print('Player2 input incorrect') sys.exit('Input Error') # Game logic. # Note that the backslash is a line continuation for long expressions if (player1 == 'rock' or player1 == 'paper' or player1 == 'scissors') \ and (player2 == 'rock' or player2 == 'paper' or player2 == 'scissors'): if player1 == player2: print ('Players Tie') elif (player1 == 'rock' and player2 == 'scissors') \ or (player1 == 'paper' and player2 == 'rock') \ or (player1 == 'scissors' and player2 == 'paper'): print('Player 1 Wins') else: print('player 2 wins') else: print('Input Incorrect')

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!