Computer Science

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

Python String Manipulation

14 Likes

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.

Answered By

9 Likes


Related Questions