What is the output of print([1, 2, 3][5:]) in Python?
print([1, 2, 3][5:])
Correct answer
C. []
C. []
The slice [5:] on a short list returns an empty list rather than raising IndexError.
Asked in: Python Interview Output Prediction
https://docs.python.org/3/reference/datamodel.htmlNot sure why the answer is C? Ask here and get an explanation.