Skip to main content

7.9) Exercise 17 - 421 Dice Game


421 or four-twenty-one is a French dice game. Write a program to play that game.
The rules are as follows:

  • You roll three dice
  • If you get a 4, a 2 and a 1, the computer says 'Hooray, 421!'
  • If you get three of a kind, the computer says 'Great, I got triple x' where 'x' is the number you rolled
  • If you get two of a kind, the computer says 'Not too bad, double x'
  • Otherwise, the computer says 'Too bad!'

Hint: you might want to sort the dice values before assessing the outcome.
Solution: challenge_421_dice_game.py