fork download
  1. names = sorted(['img_6568-001', 'img_6563-001','img_6573-001'])
  2. indices = [i for i in range(len(names[0])) if not all(name[i] == names[0][i] for name in names)]
  3. start_num = int(''.join(names[0][i] for i in indices))
  4. end_num = int(''.join(names[-1][i] for i in indices))
  5. pattern = names[0][:indices[0]] + "%d" + names[0][indices[-1]+1:]
  6. all_names = [pattern % i for i in range(start_num, end_num)]
  7. for name in all_names:
  8. print(name)
Success #stdin #stdout 0.02s 9984KB
stdin
Standard input is empty
stdout
img_6563-001
img_6564-001
img_6565-001
img_6566-001
img_6567-001
img_6568-001
img_6569-001
img_6570-001
img_6571-001
img_6572-001