Advertisements
Advertisements
Question
What does the list.remove(x) method do in Python?
Options
Removes the element at index x from the list.
Removes the first occurrence of value x from the list.
Removes all occurrences of value x from the list.
Removes the last occurrence of value x from the list.
MCQ
Solution
Removes the first occurrence of value x from the list.
Explanation:
list.remove(x) finds the first occurrence of the value x in the list. If it discovers x, it removes it. If the value x does not appear in the list, it throws a ValueError.
shaalaa.com
Is there an error in this question or solution?