Function/method returning list of chars in string?
Hendrik van Rooyen
mail at microcorp.co.za
Tue Jun 9 03:25:12 EDT 2009
One can go from lb = ['b','a','n','a','n','a']
to s = "banana" by using s = "".join(lb)
Is there a way to go the reverse route?
I have not been able to find one.
It is obviously easy to write a for char in s loop
or list comprehension, but there seems to be
no function or string method to return a list
of characters.
using lb = s.split("") would have been nice
as a complement to s = "".join(lb).
Split is already full of magic, it could do with more.
- Hendrik
More information about the Python-list
mailing list