In Python string is iterable. This means it supports special protocol.
>>> s = '123'
>>> i = iter(s)
>>> i
>>> i.next()
'1'
>>> i.next()
'2'
>>> i.next()
'3'
>>> i.next()
Traceback (most recent call last):
File "", line 1, in
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']