+ 4
The list constructor takes an iterable (like a string in this case) and returns a list. In your case, this should be roughly equivalent to def myList(iterator): tempList = [] for i in iterator: tempList += [i] return tempList Iterating over a string will return it one char at a time, hence a == ['a', 'b', 'c'].
8th Apr 2017, 5:48 PM
Tob - avatar
if you want to see what something does, just use a print function a = 'abc' a = list(a) print(a) print function is also useful for finding bugs. not sure why an if/else is returning the way it is, print what your checking and see if the output is matching your expectations. Things like that
8th Apr 2017, 7:53 PM
LordHill - avatar