In this challenge, we will use a step by step approach to create a 2-player dice game with the following rules:
- The first player rolls a pair of dice, and keeps rolling the dice again and again, until they roll a double six.
- It is then the turn of the the second player. They too will roll the dice and keep doing so until they roll a double six.
- The winner of the game is the user who rolled a double six in the smaller number of attempts.
- The game ends on a draw if both players used the same number of attempts to roll a double six.
So let’s tackle this Python challenge one step at a time… You will need to type your code in the code window below, using the step by step checklist provided underneath the code window.
Step by Step Checklist!
|Step 1: Displaying a welcome banner
|Step 2: Retrieving the name of the first player
|Step 3: Throwing the first dice…
Here is the Python code to generate a random number from 1 to 10:
import random number=random.randint(1,10)
|Step 4: Throwing the second dice…
|Step 5: Carry on throwing the dice until a double six is rolled.
|Step 6: Counting the number of throws.
|Step 7: Player 2’s turn…
|Step 8: Deciding who wins the game!