What is the output of the following Python code snippet?
try:
[].pop()
except IndexError:
print('IndexError')
[].pop()
except IndexError:
print('IndexError')
Correct answer
B. IndexError
6 views
B. IndexError
6 views
pop() on an empty list raises IndexError.
Asked in: Python Interview Lists
https://docs.python.org/3/tutorial/datastructures.htmlNot sure why the answer is B? Ask here and get an explanation.