Computer Science

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])

Python List Manipulation

30 Likes

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].

Answered By

17 Likes


Related Questions