0

Please tell me why it doesn't output anything else than [ ]

https://code.sololearn.com/cB9zj5ExnJ25/?ref=app

13th Dec 2020, 9:34 AM
Purunjay Yadav
Purunjay Yadav - avatar
2 Answers
+ 2
a = [43,6446,"Purunjay",9.5] print(a[-4:]) #Remove the 0 at the end of the slice. #Another thing, a[-4] is out of index that works but may confuse you in other situations, so it is better to use a[:] or a[0:] or just "a"
13th Dec 2020, 9:35 AM
noteve
noteve - avatar
+ 1
lst=[i:j] 3) IfĀ iĀ orĀ jĀ is negative, the index is relative to the end of sequenceĀ s:Ā len(s)Ā +Ā iĀ orĀ len(s)Ā +Ā jĀ is substituted. But note thatĀ -0Ā is stillĀ 0. 4) The slice ofĀ sĀ fromĀ iĀ toĀ jĀ is defined as the sequence of items with indexĀ kĀ such thatĀ iĀ <=Ā kĀ <Ā j. IfĀ iĀ orĀ jĀ is greater thanĀ len(s), useĀ len(s). IfĀ iĀ is omitted orĀ None, useĀ 0. IfĀ jĀ is omitted orĀ None, useĀ len(s). IfĀ iĀ is greater than or equal toĀ j, the slice is empty. read the official docs : https://docs.python.org/3/library/stdtypes.html#typesseq-common
13th Dec 2020, 9:50 AM
Ratnapal Shende
Ratnapal Shende - avatar