Which fix removes the bug?
nums = [1, 2, 3] print(nums[len(nums)])
- Index with len - 1
- Use a while loop
- Convert to a tuple
- Slice with [0:len]
Indices run 0..len-1, so len itself is always one past the end.
Play Problem Solving ▸
nums = [1, 2, 3] print(nums[len(nums)])