On 12/01/07, Christopher Spears <[EMAIL PROTECTED]> wrote: > Let's say I have a series of files that are named like > so: > > 0001.ext > 0230.ext > 0041.ext > 0050.ext > > How would I convert these from a padding of 4 to a > padding of 1? In other words, I want the files to be > renamed as: > > 1.ext > 230.ext > 41.ext > 50.ext > > At first I used strip(), which was a mistake because > it removed all the zeroes.
Are you sure? If you used .replace('0', '') it would remove all the zeros. But this is what strip is for. >>> lst = ['0001.ext', '0230.ext', '0041.ext', '0050.ext'] >>> [s.lstrip('0') for s in lst] ['1.ext', '230.ext', '41.ext', '50.ext'] -- John. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor