In Python string is iterable. This means it supports special protocol.
>>> s = '123'
>>> i = iter(s)
>>> i
<iterator object at 0x00E82C50>
>>> i.next()
'1'
>>> i.next()
'2'
>>> i.next()
'3'
>>> i.next()
Traceback (most recent call last):
File "<pyshell#7>", line 1, in <module>
i.next()
StopIteration
list
constructor may build list of any iterable. It relies on this special method next
and gets letter by letter from string until it encounters StopIteration
.
So, the easiest way to make a list of letters from string is to feed it to list
constructor:
>>> list(s)
['1', '2', '3']