CBSE Class 11 Computer Science Question 53 of 91

String Manipulation — Question 13

Back to all questions
13
Question

Question 13

In a string slice, the start and end values can be beyond limits. Why?

Answer

String slicing always returns a subsequence and empty subsequence is a valid sequence. Thus, when a string is sliced outside the bounds, it still can return empty subsequence and hence Python gives no errors and returns empty subsequence.

Answer