Hi, I would do it as follows, adding 0s to front to make them valid PINs. while counter < howmany:
pin = randint(0000,9999) print "%04i" % (pin) counter += 1 On 10/09/2007, Vishnu Mohan <[EMAIL PROTECTED]> wrote: > > > > Now I just need to figure out how to only get 4 digit pin numbers :) > > > Use regular expressions.... > The following is the code with re. > > > from random import randint > import re > > counter = 0 > pinPattern = re.compile(r'^\d{4}$') > howmany = raw_input( "How many: " ) > if pinPattern.match(howmany): > while counter < int(howmany): > pin = randint(0000,9999) > print pin > counter += 1 > else: > print "%s is not valid 4 digit integer"%howmany > > > -vishnuMohan > -- Michael Connors
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor