[Tutor] string.split() into a list

Kent Johnson kent37 at tds.net
Tue Oct 18 23:35:48 CEST 2005


Randy Bush wrote:
> maybe it's that i am actually doing
> 
>    l = []
>    a, l = string.split('|')

How about 
 >>> s='1|2|3|4'
 >>> l=s.split('|')
 >>> a, l = l[0], l[1:]
 >>> a
'1'
 >>> l
['2', '3', '4']
?

Kent


> 
> ?
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
> 
> 



More information about the Tutor mailing list