Re: [Tutor] Generate 8 digit random number

2005-09-02 Thread Jacob S.
> Hey Tutors > > I saw a lot of responses...After analyze them I have resumed two > approaches > > 1.- Generate a random number from 0 to and fill this number with > zeros (Almost everyone's approach) > 2.- Generate 8 random numbers and join them (Pietro and someone else) > > Which one of

[Tutor] Generate 8 digit random number

2005-08-27 Thread Alberto Troiano
Hey Tutors I saw a lot of responses...After analyze them I have resumed two approaches 1.- Generate a random number from 0 to and fill this number with zeros (Almost everyone's approach) 2.- Generate 8 random numbers and join them (Pietro and someone else) Which one of this is more ran

Re: [Tutor] Generate 8 digit random number

2005-08-26 Thread Michael P. Reilly
On 8/26/05, Alberto Troiano <[EMAIL PROTECTED]> wrote: Hi everyoneI need to generate a password..It has to be an 8 digit number and it has tobe randomThe code I've been trying is the following:import randomrandom.randrange(,) The code works but sometimes it picks a number with 7 dig

Re: [Tutor] Generate 8 digit random number

2005-08-26 Thread Terry Carroll
On Fri, 26 Aug 2005, Alberto Troiano wrote: > I need to generate a password..It has to be an 8 digit number and it has > to be random > > import random > random.randrange(,) > > The code works but sometimes it picks a number with 7 digits. Is there any > way that I can tell him

Re: [Tutor] Generate 8 digit random number

2005-08-26 Thread Alan Gauld
> I need to generate a password..It has to be an 8 digit number and it > has to be random I assume you mean a string representing an 8 digit random number? If so... > import random > random.randrange(,) > > The code works but sometimes it picks a number with 7 digits. Is > there a

Re: [Tutor] Generate 8 digit random number

2005-08-26 Thread Ertl, John
[mailto:[EMAIL PROTECTED] Sent: Friday, August 26, 2005 1:50 PM To: Alberto Troiano; tutor@python.org Subject: Re: [Tutor] Generate 8 digit random number Hi Alberto, Here's how to do it: --- import random def generateKey():

Re: [Tutor] Generate 8 digit random number

2005-08-26 Thread Ertl, John
ROTECTED] Sent: Friday, August 26, 2005 1:50 PM To: Alberto Troiano; tutor@python.org Subject: Re: [Tutor] Generate 8 digit random number Hi Alberto, Here's how to do it: --- import random def generateKey(): nums = "0123

Re: [Tutor] Generate 8 digit random number

2005-08-26 Thread Byron
Hi Alberto, Here's how to do it: --- import random def generateKey(): nums = "0123456789" strNumber = "" count = 0 while (count < 8): strNumber += nums[random.randrange(len(nums))] count += 1 pri

Re: [Tutor] Generate 8 digit random number

2005-08-26 Thread Alberto Troiano
nt Johnson <[EMAIL PROTECTED]> >CC: tutor@python.org >Subject: Re: [Tutor] Generate 8 digit random number >Date: Fri, 26 Aug 2005 10:16:37 -0400 > >Alberto Troiano wrote: > > Hi Kent > > > > Nope... > > Not workingI'm still getting 7 even 6

Re: [Tutor] Generate 8 digit random number

2005-08-26 Thread Kent Johnson
range(1000,) ... if len(str(x)) < 8: ... print x ... >>> (prints nothing - they are all 8 digits) Kent > > Any other idea? > > Thanks > > Alberto > >> From: Kent Johnson <[EMAIL PROTECTED]> >> CC: tutor@python.org

Re: [Tutor] Generate 8 digit random number

2005-08-26 Thread Pietro Ciuffo
On Fri, Aug 26, 2005 at 01:50:04PM +, Alberto Troiano wrote: > Hi everyone > > I need to generate a password..It has to be an 8 digit number and it has to > be random > > The code I've been trying is the following: > > > import random > random.randrange(,) > > The code wor

Re: [Tutor] Generate 8 digit random number

2005-08-26 Thread Alberto Troiano
Hi Kent Nope... Not workingI'm still getting 7 even 6 digits number Any other idea? Thanks Alberto >From: Kent Johnson <[EMAIL PROTECTED]> >CC: tutor@python.org >Subject: Re: [Tutor] Generate 8 digit random number >Date: Fri, 26 Aug 2005 10:00:50 -0400 > >

Re: [Tutor] Generate 8 digit random number

2005-08-26 Thread Pierre Barbier de Reuille
Is "0" a valid digit for your password ? If the answer is "YES" then, remember that the "0" at the left of a number are juste removed ! In that case, try writing your password with : "%08d" % password Pierre Alberto Troiano a écrit : > Hi everyone > > I need to generate a password..It has to b

Re: [Tutor] Generate 8 digit random number

2005-08-26 Thread Kent Johnson
Alberto Troiano wrote: > Hi everyone > > I need to generate a password..It has to be an 8 digit number and it has to > be random > > The code I've been trying is the following: > > > import random > random.randrange(,) > > The code works but sometimes it picks a number with 7

[Tutor] Generate 8 digit random number

2005-08-26 Thread Alberto Troiano
Hi everyone I need to generate a password..It has to be an 8 digit number and it has to be random The code I've been trying is the following: import random random.randrange(,) The code works but sometimes it picks a number with 7 digits. Is there any way that I can tell him t