i'm new to Python but learning with up's and downs.
I don't understand this bit of code:
To iterate over the indices of a sequence, combine range() and len() as follows:
>>> a = ['Mary', 'had', 'a', 'little', 'lamb']
>>> for i in range(len(a)):
... print i, a[i]
...
0 Mary
1 had
2 a
3 little
4 lamb
Pretty straight forward. But i don't see in print i, a[i] where the extra [i] comes into play. (Due to my little knowledge of python, no doubt).
But if somebody's willing to nudge me in the right direction, i'd be very happy.
enumerate.[i]is an index - recall from section 3 of the tutorial that you hadword = HelpAresulting inword[4] = A. That's because when you used the index 4 there, you asked for the element in position4inword. (Also remember that the leftmost element is in position 0, soword[0] = H,word[1]=e,word[2]=l,word[3]=p,word[4]=A).