Re: Beginners Query - Simple counter problem

2007-09-06 Thread [EMAIL PROTECTED]
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): > >

Re: Beginners Query - Simple counter problem

2007-09-06 Thread Zentrader
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

Re: Beginners Query - Simple counter problem

2007-09-06 Thread David Barr
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. >

Re: Beginners Query - Simple counter problem

2007-09-06 Thread Ian Clark
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

Re: Beginners Query - Simple counter problem

2007-09-06 Thread Carsten Haese
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

Re: Beginners Query - Simple counter problem

2007-09-06 Thread Ian Clark
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

Re: Beginners Query - Simple counter problem

2007-09-06 Thread Carsten Haese
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

Re: Beginners Query - Simple counter problem

2007-09-06 Thread J Sisson
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

Re: Beginners Query - Simple counter problem

2007-09-06 Thread Scott David Daniels
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