> 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
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
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
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
> 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
[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():
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
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
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
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
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
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
>
>
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
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
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
15 matches
Mail list logo