Computer Science
Find the errors:
L1 = [1, 11, 21, 31]
An = L1.remove(31)
print(An + 2)
Python List Manipulation
21 Likes
Answer
An + 2 will cause an error because remove() function does not return the removed element so An will be None. Addition operator (+) does not allow any of its operands to be None hence, it will raise a TypeError.
Answered By
9 Likes
Related Questions
Find the errors:
- L1 = [1, 11, 21, 31]
- L2 = L1 + 2
- L3 = L1 * 2
- Idx = L1.index(45)
Find the errors:
L1 = [1, 11, 21, 31] An = L1.remove(41)
Find the errors:
L1 = [3, 4, 5] L2 = L1 * 3 print(L1 * 3.0) print(L2)
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])