I'm confused with some python basics. I have my list:
myList = ['a','b','c','d','e','f']
now I would like to print this list using index and range:
for i in range(0, len(myList)):
print(myList[i])
I got:
a
b
c
d
e
f
My first question: Why I shouldn't use len(myList)-1? len(myList) returns 6 but when I use directly print(myList[6]) I got out of range error. Why using this in for loop is different?
Second. I know I can use myList.reverse() but I would like to print reversed list like this:
for i in range(len(myList), 0, -1):
print(myList[i])
I get out of range and I should add -1:
for i in range(len(myList)-1, 0, -1):
print(myList[i])
but after this I got only:
f
e
d
c
b
My second question: where is "a"? ;) and why in this example I have to use len(myList)-1?