Strings for a newbie
Malcolm Wooden
mwooden at dtptypes.com
Fri May 27 08:59:41 EDT 2005
my actual code is:
for x in range(len(l)):
h = string.split(l[x])
where the sentence string is in an array of one element 'l'
Error is:
Traceback (most recent call last):
File "<string>", line 34, in ?
File "<string>", line 27, in SentenceText
File "C:\PYTHON22\lib\string.py", line 122, in split
return s.split(sep, maxsplit)
AttributeError: 'list' object has no attribute 'split'
"John Machin" <sjmachin at lexicon.net> wrote in message
news:42971235.9000805 at lexicon.net...
> Malcolm Wooden wrote:
>> Sorry John but that don't do it for me. Just get errors comming back
>>
>>
>> "John Machin" <sjmachin at lexicon.net> wrote in message
>> news:42970d69 at news.eftel.com...
>>
>
>>>
>>>>>>s = "This is a sentence of words"
>>>>>>a = s.split()
>>>>>>a
>>>
>>>['This', 'is', 'a', 'sentence', 'of', 'words']
>>>
>
> Malcolm,
>
> What errors did you get? Please post a copy of what you see on your
> screen; my palantir is on the fritz :-)
>
> Cheers,
> John
More information about the Python-list
mailing list