Computer Science, asked by veerajsai, 6 months ago

Given a list L=[10,20,30,40,50,60,70] what would L[-4:-1) return?​

Answers

Answered by binitsen7354
6

Answer:

[ 40, 50 , 60 ]

Explanation: the loop runs from start to (stop-1) with given step value

Answered by dreamrob
4

L = [10 , 20 , 30 , 40 , 50 , 60 , 70]

print(L[-4 , -1])

L = [10 , 20 , 30 , 40 , 50 , 60 , 70]

      0      1     2     3      4      5     6       index

     -7     -6   -5    -4     -3    -2     -1       negative index

L[starting index , ending index - 1]

So, the elements on index -4, -3 and -2 will be displayed.

Therefore, the output is [40 , 50 , 60]

Similar questions