|
|
|
|
|
by hk__2
1025 days ago
|
|
> It seems altogether surprising that with an empty list or tuple a, a[1] results in index error, yet a[1:] quietly returns an empty list or tuple. `a[1:]` returns the sequence of elements that start at index 1. If there is no such element, the list is empty. I don’t see any good reason why this should throw an error. |
|
This could easily conceal the indexing error unless the caller code explicitly checks the length of the returned section.