0
List slices PRO exercise problem
Why is the output 2 and not 42? Can someone please explain this to me? ------------------- x = input() elements = x.split() print(x[:-2:-1]) ------------------- input: [42] output: 2
3 odpowiedzi
+ 2
some tutorial
https://code.sololearn.com/cAQBZ3dHmbKW/?ref=app
+ 3
in indexing Im sure you know you have your [start:stop:step]
if x is a list of two items, then print(x[:-2:-1]) means:
print a list of all the values in the list reversed (-1), up to but not including the second to last value in the original list (-2).
0
Thank you! :D