I'm trying to split the elements of a list:
text = ['James Fennimore Cooper\n', 'Peter, Paul, and Mary\n',
'James Gosling\n']
newlist = ['James', 'Fennimore', 'Cooper\n', 'Peter', 'Paul,', 'and', 'Mary\n',
'James', 'Gosling\n']
My code so far is:
newlist = []
for item in text:
newlist.extend(item.split())
return newlist
And I get the error:
builtins.AttributeError: 'list' object has no attribute 'split'