21.6k views
2 votes
When referencing a substring such as str1[m:n] if m >= n then the value will be?

User Silverspur
by
4.9k points

1 Answer

2 votes

Answer: '' (An empty string)

Step-by-step explanation:

Normally, when we are getting a substring, we will start from the character at index m and go until, but exclude the character at index n.

If m is greater than n, then we cannot get any substring as we would have to go backwards when we need to go forwards. If m=n, then we still cannot get any characters as we have to exclude the character at index n, making us have to exclude the character at index m as well.

Hence, for both situations the value would be an empty string, or a string with length 0.

User Theftprevention
by
5.8k points