Question 3
Back to Exercise
What is the output of the following Python program?
s = "hello"
print(repr(s[10:]), len(s[1:100]), s[-100:2])
- A '' 4 he Correct
- B IndexError
- C '' 5 he
- D None 4 he
Correct Answer: Option A
Out-of-range slice bounds are clipped to the string: s[10:] is empty, s[1:100] is "ello", s[-100:2] is "he".
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!