range with variable leading zeros

yhvh yhvh2000 at googlemail.com
Fri May 9 06:01:22 EDT 2008


> > x = [0010, 0210]
>
> You do realize that this is octal, right?
It's unfortunate I choose that, the numbers go beyond octal

> len is undefined for integers.  Perhaps you meant "len(str(x[1]))".
Yes sorry it was late at night :P


> You can, however, do this:
> >>> '%0*d' % (5, 123)
> '00123'

This is exactly what I needed Thank-you kindly



More information about the Python-list mailing list