Reputation: 25
I am trying to generate a python list similar to this:
['888_tir01','888_tir02','888_tir03','888_tir04'.........]
my question is how to generate such list? I have thinking to create a list like this
['888_tir0']*100
and then concatinate the numbers with each element but don't know the easy way. I appreciate any suggestions. thanks! Best Regards
Upvotes: 1
Views: 67
Reputation: 195438
Use str.format
:
out = ['888_tir{:02d}'.format(i) for i in range(1, 100)]
print(out)
Prints:
['888_tir01', '888_tir02', '888_tir03', ...
Upvotes: 1