Home

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

previous
next

Re: Free C++compilers for a classroom
Re: Let's Unite Against Jews and Mongrels!
Re: shutil.copy2 error
Re: Python 3K or Python 2.9?
Re: Object Management
odnawialne źródła energii
zegarki tissot
internet
ecommerce
laptopy