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
Find the errors:
L1 = [1, 11, 21, 31] An = L1.remove(31) print(An + 2)
Find the errors:
L1 = [3, 4, 5] L2 = L1 * 3 print(L1 * 3.0) print(L2)
What will be the output of following code?
x = ['3', '2', '5'] y = '' while x: y = y + x[-1] x = x[:len(x) - 1] print(y) print(x) print(type(x), type(y))
Complete the code to create a list of every integer between 0 and 100, inclusive, named nums1 using Python, sorted in increasing order.