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
Try to find out if for any case, the string functions isalnum( ) and isalpha( ) return the same result
Suggest appropriate functions for the following tasks:
- To check whether the string contains digits
- To find for the occurrence a string within another string
- To convert the first letter of a string to upper case
- to capitalize all the letters of the string
- to check whether all letters of the string are in capital letters
- to remove from right of a string all string-combinations from a given set of letters
- to remove all white spaces from the beginning of a string
Can you specify an out of bound index when accessing a single character from a string? Why?
Can you add two strings? What effect does ' + ' have on strings?