I'm trying to sort my confusions learning python.
>>> cities = ['London', "Toronto", 'Paris', 'Oslo']
>>> cities
['London', 'Toronto', 'Paris', 'Oslo']
>>> for i in cities:
... print(i)
...
London Toronto Paris Oslo
>>> for i in cities:
... print(cities[i])
...
Traceback (most recent call last): File "", line 2, in TypeError: list indices must be integers or slices, not str
>>> cities[0]
'London'
In the loop, it refuses the index, but outside of the loop, it seems to accept. Confused!!!