What does this Python code print?
values = [1, 2, 4]
print(values[-1])Answer & explanation
Answer: 4
Index -1 selects the last element.
Practice lists & slicing with self-contained questions. Check your answer, then use the explanation to understand the reasoning.
values = [1, 2, 4]
print(values[-1])Answer: 4
Index -1 selects the last element.