Hi,
I would do it as follows, adding 0s to front to make them valid PINs.
while counter < howmany:
pin = randint(,)
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 numbe
> 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):
whil
matte wrote:
> Hi guys
>
> Please excuse me but I've been out of Python for a while since my laptop
> was stolen...
>
> I'm battling with a very basic while loop
>
> -- 8< --
> #!/usr/bin/python
>
> from random import randint
>
> counter = 0
>
> howmany = r
You could use string formatting to output all pin numbers as 4 character
strings.
http://docs.python.org/lib/typesseq-strings.html
On 07/09/2007, matte <[EMAIL PROTECTED]> wrote:
>
> Perfect...
>
> Thanks very much for your help...
>
> On 9/7/07, Michael Connors <[EMAIL PROTECTED]> wrote:
> >
> >
Perfect...
Thanks very much for your help...
On 9/7/07, Michael Connors <[EMAIL PROTECTED]> wrote:
>
> I think it will work if you cast your input to an int:
> howmany = int(raw_input( "How many: " ))
Now I just need to figure out how to only get 4 digit pin numbers :)
-m
_
I think it will work if you cast your input to an int:
howmany = int(raw_input( "How many: " ))
On 07/09/2007, matte <[EMAIL PROTECTED]> wrote:
>
> Hi guys
>
> Please excuse me but I've been out of Python for a while since my laptop
> was stolen...
>
> I'm battling with a very basic while loop