[Tutor] string.split() into a list

Jason Massey jason.massey at gmail.com
Tue Oct 18 22:34:17 CEST 2005


Works fine for me:

>>> l = []
>>>a='1|2|3|4'
>>> l=a.split('|')
>>>l
['1', '2', '3', '4']


On 10/18/05, Randy Bush <randy at psg.com> wrote:
> and stupid question of the morning (for me)
>
> i want to string.split() into a sequence, a la
>
>   l = []
>   l = myString.split('|')
>
> but, of course it whines about too many values.  what is the
> common way to do this?
>
> randy
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list