Please tell me why it doesn't output anything else than [ ] | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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