CBSE Class 11 Computer Science Question 80 of 104

List Manipulation — Question 16

Back to all questions
16
Question

Question 14b

Find the errors:

L1 = [3, 3, 8, 1, 3, 0, '1', '0', '2', 'e', 'w', 'e', 'r']
print(L1[: :-1])
print(L1[-1:-2:-3])
print(L1[-1:-2:-3:-4])

Answer

The line print(L1[-1:-2:-3:-4]) causes an error as its syntax is invalid. The correct syntax for slicing a list is L1[start:stop:step].

Answer