[Tutor] Splitting a string into a list.
Francois Granger
fgranger@altern.org
Thu, 25 Jul 2002 10:27:38 +0200
At 4:10 +0200 25/07/02, in message [Tutor] Splitting a string into a
list., Troels Leth Petersen wrote:
>Isn't there a built-in that does the following:
>
>>>> liste = []
>>>> for char in thing:
>... liste.append(char)
>...
>>>> liste
>['l', 'o', 't', 't', 'o']
> >>>
Aside from the list() builtin, you can treat a string as a non mutable list.
for exemple:
>>> a = 'toto'
>>> for b in a[:]:
... print b
...
t
o
t
o
>>>