fork download
  1. import re
  2. input = ['90-10-07457', '000480087800784', '001-713-0926', '12-710-8197', '1-345-1715', '9-23-4532', '000200007100272']
  3. output = ['00090-00010-07457', '000480087800784', '00001-00713-00926', '00012-00710-08197', '00001-00345-01715', '00009-00023-04532', '000200007100272']
  4.  
  5. ## I have tried this -
  6.  
  7. import re
  8. new_list = []
  9. for i in range (0, len(input)):
  10. splits = input[i].split('-')
  11. if len(splits) == 1:
  12. new_list.append(input[i])
  13. else:
  14. new_list.append("{}-{}-{}".format(splits[0].zfill(5), splits[1].zfill(5), splits[2].zfill(5)))
  15.  
  16. ## problem is with second argument '0000\\1'. I know its wrong but unable to solve
  17. print(new_list) ## new_list is the expected output.
  18. print(output)
Success #stdin #stdout 0.02s 27712KB
stdin
Standard input is empty
stdout
['00090-00010-07457', '000480087800784', '00001-00713-00926', '00012-00710-08197', '00001-00345-01715', '00009-00023-04532', '000200007100272']
['00090-00010-07457', '000480087800784', '00001-00713-00926', '00012-00710-08197', '00001-00345-01715', '00009-00023-04532', '000200007100272']