Carsten Haese wrote: > On Thu, 2007-09-06 at 11:00 -0700, Scott David Daniels wrote: >> def d6(count): >> result = 0 >> for die in range(count): >> result += random.randint(1, 6) >> return result > > This, of course, can be further improved into: > > def d6(count): > return sum(random.randint(1, 6) for die in range(count)) >
My stab at it: >>> def roll(times=1, sides=6): ... return random.randint(times, times*sides) Ian -- http://mail.python.org/mailman/listinfo/python-list