Okay, I'm sure this question is a bit trivial, but I'm curious!
In python, it is completely legal to do this:
a = [1,2,3,4,5]
print(a[:123])
>> [1, 2, 3, 4, 5]
but as soon as you try to do this:
a = [1,2,3,4,5]
print(a[123])
>> IndexError: list index out of range
Why is this so, in the context of how it is stored in memory and interpreted by the compiler?
I have tried storing the first example in a variable and checking the length of that variable but it is simply the length of the original list, ignoring the subsequent empty places.
I'm genuinely curious and interested to see what the answers are!