Get the Number of Rounds

Learn how to specify the number of rounds.

What have we got?

We have set up a function to print the introduction of the game. This is our inventory of already created functions:

# Function to display game instructions
def display_instructions():
    print('Welcome to Rock Paper Scissors.\n')
    print('The rules are simple:')
    print('1. Rock beats scissors')
    print('2. Scissors beat paper')
    print('3. Paper beats rock')

The next step is to ask the user about the number of rounds. This specifies how many times our game will run.

What’s next?

We need to create a function that asks users to input the total number of rounds they want to play and store it in a variable. These are the steps we need to perform in this task:

  • Take the input from the user and store it in a variable.
  • Converting the input string to an integer.
  • Return the variable.

Note: You may assume the user will only provide a number when prompted.

Try it yourself

Write your code in the code widget below and click the “Run” button to execute your code.

If you’re unsure how to do this, click the “Show Hint” button.

Get hands-on with 1400+ tech skills courses.