saving . . . saved Slicing a list has been deleted. Slicing a list has been hidden .
Slicing a list
Title
Question
week_name=["mon","tue","wed","thu","fri","sat","sun"]
why does week_name[-1:-5] returns [ ]

Python-3.4.3 Manipulating-lists 01-02 min 50-60 sec 18-08-20, 12:41 p.m. Mitalidas

Answers:

The pointer that traverses the list when slicing or striding only moves from left to right, so when you say week_name[-1:-5], the interpreter tries to start from -1 (sun) and move towards the right to fetch more elements, however there are no more elements to the right of -1 hence it returns an empty list
07-09-20, 10:29 p.m. ankitrj.iitb


Log-in to answer to this question.