Skip to main content

7.8) Exercise 16 - Three Of A Kind Dice Game


Write a dice game program following these instruction:

  1. roll three dice using the random.randint function
    • random.randint(a, b) : returns a random integer N such that a <= N <= b.
    • you have to import the random module to use that function.
  2. check the outcome of the dice roll
    • if you roll three sixes, print: 'best hand, triple 6'
    • if you roll three of a kind, print: 'pretty good, triple x', replace x with number
    • for any other result, print 'too bad'

Solution: if_exercise_three_of_a_kind.py