+ 1
Output of the below code and why is that output printed?
squares=[0,1,4,8,64,81] print(squares[1:1:-1]) Can some please explain me What is the output of the code and why?
4 Answers
+ 3
Output is : []
an empty list.
Beacause, in normal slicing [1:1] is also an empty one. Now you cannot reverse an empty list. So, -1 is useless here.
+ 1
Thanks Abhay . next time sure i will post with an answer and ask for explanation.
0
You should mention the output of the code and ask us why the output is this?
there is code playground for it
0
Thank you M Tamim for explaining the answer.