[Tutor] Splitting
Alan Gauld
alan.gauld at freenet.co.uk
Mon Jul 10 09:42:11 CEST 2006
> Example :-
> >>> a="43;dsds;d"
>>>>
>>>> b=a.split(';')
>
> Here I encountered the following error :-
>
> Traceback (innermost last):
> File "<stdin>", line 1, in ?
> AttributeError: 'string' object has no attribute 'split'
>
> Can anybody help on resolving this issue?
>>> a="43;dsds;d"
>>> b=a.split(';')
>>> b
['43', 'dsds', 'd']
>>>
Works for me in Python 2.4
Are you using an old version of Python? pre v2.0?
If so you need to use the string module rather than string methods.
Otherwise I don't know what might be wrong.
Alan G.
More information about the Tutor
mailing list