Skip to main content

if_exercise_three_of_a_kind.py


"""
 If statements exercise 3: three of a kind dice game
 Write a dice game program following these instruction :
1. roll three dices using the random.randint function
random.randint(a, b) : return 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 all dices are six, print: 'best hand, triple 6'
- if all dices are equal, print: 'pretty good, triple x', replace x with number
- otherwise, print 'too bad'
Author: Lauren J Gregoire
"""
from random import randint
dices=(randint(1,6),randint(1,6),randint(1,6))
print dices
#check if 3 dices are identical
if (dices[0]==dices[1]==dices[2]):
    if dices[0]==6:
        print 'best hand, triple 6'
    else:
        print 'pretty good, triple',dices[0]
else:
    print 'too bad!'