4 ms·
When you slice a list, you get a list. When you see there is nothing inside the returning list, you know that means end of list, contains zero element. Slicing
by akasakahakada 3y ago
When you slice a list, you get a list.
When you see there is nothing inside the returning list, you know that means end of list, contains zero element.
Slicing and indexing return object at different level.
- macintux 3y agoSlicing a list, when the first index is invalid for that list, could easily throw an exception instead.
- zoomablemind 3y agoThis should signal an explicit error, which invalid index is indeed. If user believes for some reason the invalid indexing is ok, then it could be caught and handled. No ambiguity.