[Tutor] Splitting a string

David Hutto smokefloat at gmail.com
Tue Feb 8 12:29:03 CET 2011


> To get a list, just ask for one:
>
>>>> list("abcd")
> ['a', 'b', 'c', 'd']
>


or., and this isn't to argue with anyone;), you could:

>>> x = 'abcd'
>>> y = []
>>> for letter in x:
...     y.append(letter)
...
>>> print y
['a', 'b', 'c', 'd']

which explains that the list is derived from the string.

x is 'abcd', and list is the list seperated at the characters, and can
be split further with string
'tags'.
>
>
> --
> Steven
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>



-- 
According to theoretical physics, the division of spatial intervals as
the universe evolves gives rise to the fact that in another timeline,
your interdimensional counterpart received helpful advice from me...so
be eternally pleased for them.


More information about the Tutor mailing list