Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python
tweaking random number
 

Index | Next | Previous | View Flat


varma.nikhil22 at gmail

May 9, 2012, 12:01 AM


Views: 335
Permalink
tweaking random number

Hi All

I want to generate a random number of 8 digits which involve 3 number and 5
digits.
Like this :-

def random_number():
# do something

random_number()
"123abcde" # first 3 numbers and 5 letters after the numbers.

I am able to generate the random number 8 digit like this:-

def random_number():
characters = list(string.ascii_lowercase + string.ascii_uppercase\
+ string.digits)
coll_rand = []
for i in range(8):
random.shuffle(characters)
coll_rand.append(characters[0])
return ''.join(coll_rand)

This generates like this "Kkrgt56r"

Thanks in advance

--
Regards
Nikhil Verma
+91-958-273-3156

Subject User Time
tweaking random number varma.nikhil22 at gmail May 9, 2012, 12:01 AM
    Re: tweaking random number python at mrabarnett May 9, 2012, 12:38 AM
    Re: tweaking random number rosuav at gmail May 9, 2012, 12:44 AM
    Re: tweaking random number __peter__ at web May 9, 2012, 1:30 AM

  Index | Next | Previous | View Flat
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.