Reputation: 3
I'm trying that at one point turns a list of integers and turns them into characters, then strings. For example:
items = [10, 20, 42]
If the three integers 10, 20, and 42 were given, I'd want to do change it into something that works in the sense of:
items = [chr(10), chr(20), chr(42)]
print(" ".join(items))
or:
items = chr(items)
print(" ".join(items))
But the second one does not work... and I need a way to do it that works if the number of items on the list is not always the same.
Upvotes: 0
Views: 362
Reputation: 330203
You easily use comprehension like this one:
" ".join(chr(x) for x in items)
Upvotes: 1