ProgrammingHardAccenture pattern

What is printed?

What is printed?
s = "abcdef"
print(s[10:20])
  1. A. IndexError
  2. B. ''
  3. C. None
  4. D. abcdef

Correct answer: B. ''

A start index far past the string's length clamps to len(s); the whole slice is then empty, so Python returns the empty string instead of raising an error.

More Python Programming questions

Exams that ask this topic