1

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

1 Answer 1

1

Use str.format:

out = ['888_tir{:02d}'.format(i) for i in range(1, 100)]
print(out)

Prints:

['888_tir01', '888_tir02', '888_tir03', ...
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! for a quick response

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.