PRACTICE / UNDERSTAND / REPEAT

Python: Lists & slicing

Practice lists & slicing with self-contained questions. Check your answer, then use the explanation to understand the reasoning.

40 questionsAnswers explainedFree · no login
Question 1 of 40
Lists & slicing · MCQQuestion link ↗

What does this Python code print?

values = [1, 2, 4]
print(values[-1])
Choose one answer
Answer & explanation

Answer: 4

Index -1 selects the last element.