Number combinations
Alex Martelli
aleax at mac.com
Wed Jul 19 10:26:34 EDT 2006
placid <Bulkan at gmail.com> wrote:
> Hi all,
>
> Just wondering if there is a better way of generating a 4 digit number
> (that gets converted to a string), ive got the following code which
> generates strings between 0000-9999.
>
> <code>
>
> for a in range(0,10):
> for b in range(0,10):
> for c in range(0,10):
> for d in range(0,10):
> print "%s%s%s%s" %(str(a), str(b), str(c),str(d)
for n in xrange(10000):
print "%4.4d" % n
Alex
More information about the Python-list
mailing list