Skip to main content
Python Output Prediction Easy +10 XP

List Slicing

What does this print?

PythonRead-only
nums = [10, 20, 30, 40, 50]
print(nums[1:3])

What is the output?

Show answer and explanation

Answer: [20, 30]

Slicing [1:3] gives elements at index 1 and 2 (end index is exclusive).

Hint: End index is exclusive.

What this challenge tests

Output Prediction in Python: lists, slicing.

Related challenges