rndom number tweaks

Nikhil Verma varma.nikhil22 at gmail.com
Wed May 9 06:17:34 EDT 2012


Hi Chris

(That's 3 digits and 5 letters) Pretty easy. Do you want to
distinguish between uppercase and lowercase letters?

No i really don't care for that. I just want first three should be numbers
and rest 5 are characters.
"123aAbBc"

Can you give examples ?

---------- Forwarded message ----------
From: Chris Angelico <rosuav at gmail.com>
To: python-list at python.org
Cc:
Date: Wed, 9 May 2012 17:44:00 +1000
Subject: Re: tweaking random number
On Wed, May 9, 2012 at 5:01 PM, Nikhil Verma <varma.nikhil22 at gmail.com>
wrote:
> Hi All
>
> I want to generate a random number of 8 digits which involve 3 number and
5
> digits.

(That's 3 digits and 5 letters) Pretty easy. Do you want to
distinguish between uppercase and lowercase letters?

Your current random_number function (btw, I wouldn't call it "number"
as it isn't one) is most of one possible solution. Divide it into two
parts, one part that generates the digits and another part that
generates the letters. Your 'characters' template would thus be
different for the two parts.

There are other solutions, which involve the generation of less random
numbers, but your way will work.

ChrisA

-- 
Regards
Nikhil Verma
+91-958-273-3156
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120509/9116b061/attachment.html>


More information about the Python-list mailing list