On May 9, 1:42 pm, yhvh <[EMAIL PROTECTED]> wrote: > I want to generate a range with variable leading zeros > > x = [0010, 0210] > padding = len(x[1]) > > for j in range(x[0], x[1]): > print (url).join('%0(pad)d(jj)'+'.jpg') %{'pad':padding, 'jj':j} > > This is syntactically incorrect, you can't insert a variable into the > string format options. Any ideas?
Concatenate the parts of the pattern string first: pat = '%0' + str(padding) + 'd' -- http://mail.python.org/mailman/listinfo/python-list