# simulate the
roll of five dice
import random
def roll_dice(stop=100):
# roll five dice
and summarize the occurrances of duplicate numbers
cnt
= 1
dd
= {}
while cnt <= stop:
dice = [random.randrange(1,7) for _ in range(5)]
# eliminate duplicates
dice1 = [i
for i in dice if i not in locals()['_[1]'].__self__]
if len(dice1) == 1:
print dice
try:
dd[len(dice1)]
= dd[len(dice1)]+1
except:
dd[len(dice1)]
= 1
cnt
+= 1
return dd
dd
= roll_dice(1000)
'''
>>> dd
{2: 9,
>>> dd
{1: 4, 2: 83, 3:
499, 4: 380,
>>> [2,
2, 2, 2, 2]
[2, 2, 2, 2, 2]
>>> dd
{1: 2, 2: 95, 3:
482, 4: 384,
>>>
'''