John Fouhy wrote: > On 12/01/07, Christopher Spears <[EMAIL PROTECTED]> wrote: >> 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']
I just want to highlight that your code uses lstrip(), not strip(). lstrip() is perfect for this problem, it removes leading characters only, in this case leading 0s. Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor