Reputation: 2185
I have a list in the following manner:
foo=[21, 38, 38, 56, 23, 19, 11, 15, 19, 13, 20, 6, 0, 8, 0, 10, 11, 0, 11, 8, 12, 5]
and I want to convert this into something like:
bar=21, 38, 38, 56, 23, 19, 11, 15, 19, 13, 20, 6, 0, 8, 0, 10, 11, 0, 11, 8, 12, 5
How should this be done?
I tried bar=''.join(foo)
but this gives me an error message.
Upvotes: 1
Views: 134
Reputation: 3483
You're looking for:
''.join(map(str, foo))
This maps each integer through str
, which can then be joined together. Though, you may want to add a comma between them:
', '.join(map(str, foo))
Upvotes: 9