Access by index:
Length of strings:
|Returns a string centered in a field of size |
|Returns the number of occurrences of |
|Returns a string left-justified in a field of size |
|Returns a string in all lowercase|
|Returns a string right-justified in a field of size |
|Returns the index of the first occurrence of |
|Splits a string into substrings at |
|Same as |
|Returns last index where the substring |
|Converts string to uppercase|
|Converts string to lowercase|
Note: As compared to lists, strings cannot be modified - strings are immutable.
sorted(str_s) does the job of converting a string into an array of its sorted characters. Returns the array.
We can use the
replace function to replace characters:
replace() is an inbuilt function in Python programming language that returns a copy of the string where all occurrences of a substring is replaced with another substring.
To check if a character is alphanumeric, use