Reputation: 1233
I want to get a list:
'abc0'
'abc1'
'abc2'
...
'abc9'
the command range(10)
returns a list of numbers from 0 to 9, but how do I add the string 'abc'
to every element in the list?
Upvotes: 0
Views: 136
Reputation: 1453
>>> ['abc' + str(i) for i in range(10)]
['abc0', 'abc1', 'abc2', 'abc3', 'abc4', 'abc5', 'abc6', 'abc7', 'abc8', 'abc9']
Upvotes: 5