Advertisements
Advertisements
प्रश्न
If L is a list with 6 elements, then which of the following statements will raise an exception?
पर्याय
L.pop (1)
L.pop (6)
L.insert(1,6)
L.insert(6,1)
MCQ
Advertisements
उत्तर
L.pop (6)
Explanation:
- Index Range: A list with 6 elements has indices from 0 to 5.
- L.pop(6): This tries to remove an element at index 6, which does not exist. This results in an IndexError.
- L.insert: Unlike
pop, theinsertmethod never raises an error; if the index is too high, it simply adds the item to the end of the list.
shaalaa.com
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
