$ ./guess_the_languageProblem Solving — predict the output
Problem Solving — predict the output · medium · #33

What is printed?

nums = [0, 1, 2, 3, 4]
print(nums[1:4])
  1. [1, 2, 3, 4]
  2. [0, 1, 2, 3]
  3. [2, 3, 4]
  4. [1, 2, 3]
Slicing [1:4] includes indices 1, 2, 3 but not 4.
Play Problem Solving ▸