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
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
