AttributeError: 'list' object has no attribute 'split'

sp3cro picture sp3cro · Nov 15, 2014 · Viewed 71.1k times · Source

Using Python 2.7.3.1

I don't understand what the problem is with my coding! I get this error: AttributeError: 'list' object has no attribute 'split

This is my code:

myList = ['hello']

myList.split()

Answer

user3885927 picture user3885927 · Nov 15, 2014

You can simply do list(myList[0]) as below:

>>> myList = ['hello']
>>> myList=list(myList[0])
>>> myList
['h', 'e', 'l', 'l', 'o']

See documentation here