On Sep 6, 1:44 pm, Carsten Haese <[EMAIL PROTECTED]> wrote:
> On Thu, 2007-09-06 at 11:24 -0700, Ian Clark wrote:
> > Carsten Haese wrote:
> > > def d6(count):
> > > return sum(random.randint(1, 6) for die in range(count))
>
> > My stab at it:
>
> > >>> def roll(times=1, sides=6):
> >
On Sep 6, 10:29 am, David Barr <[EMAIL PROTECTED]> wrote:
> yields no results.
Since every response so far has answered everything __Except The
Question You Asked__, your code runs fine on my Linux machine and
prints 15. The error may be before this bit of code so it isn't
getting called. Add so
Scott David Daniels wrote:
> David Barr wrote:
>> I am brand new to Python (this is my second day), and the only
>> experience I have with programming was with VBA. Anyway, I'm posting
>> this to see if anyone would be kind enough to help me with this (I
>> suspect, very easy to solve) query.
>
Carsten Haese wrote:
> On Thu, 2007-09-06 at 11:24 -0700, Ian Clark wrote:
>> Carsten Haese wrote:
>>> 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
On Thu, 2007-09-06 at 11:24 -0700, Ian Clark wrote:
> Carsten Haese wrote:
> > 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)
That produces
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):
> r
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
Silly question, but are you importing random somewhere in that file?
It works on both my XP machine and my Linux machine (both from CLI) after
importing random...though it runs through this:
while count <= i:
i + 1 times...(You initialize count to 0, then loop over it until it hits
i+1 (at which
David Barr wrote:
> I am brand new to Python (this is my second day), and the only
> experience I have with programming was with VBA. Anyway, I'm posting
> this to see if anyone would be kind enough to help me with this (I
> suspect, very easy to solve) query.
>
> The following code is in a fi