PyMasterPython trace & interview prep
← Home

Python List Tracing Problems

Lists combine indexing, slicing, and aliasing. A single shared reference can surprise candidates who assume copies. These exercises mirror Amazon and startup screens.

Example problems

Slice assignment

a = [1, 2, 3, 4]
a[1:3] = [9]
print(a)

Output: [1, 9, 4]

Alias

x = [1, 2]
y = x
y.append(3)
print(x, len(y))

Output: [1, 2, 3] 3

Pop return

nums = [10, 20, 30]
print(nums.pop(), nums)

Output: 30 [10, 20]

Generate 100+ more problems instantly

AI-powered unique questions for lists at every difficulty.