Am learning Python for school and reading a Python textbook, I come across one part that I don't understand.
Is there a mistake in the book? or am I missing something here? Please advise, thanks.
>>> grades = ['A', 'B', 'C', 'D', 'F'] >>> grades[2:4] ['C', 'D']Going by the Python String Indexing logic, the first position starts from 0 so by logic, 'A' is 0 and the output 'C' is correct which is 2. But I don't understand why 4 is 'D' when it should been 'F' instead since Indexing starts from 0.
Is there a mistake in the book? or am I missing something here? Please advise, thanks.