A String is a combination of sequence characters. Strings can be created in Python by enclosing them around quotes. Python is designed in such a way that single or double quotes are one and the same, both work in similar way. The index of the string starts from Zero.
Str1 = “Hello python!!”
Str2 = ‘Python string example’
1. len(String) : Length method will return the string length count.
Example : str = “python language”
Here the length of the string “Python language” is 15 because index of the string
Starts with zero.
2. lower() : Converts the complete string into lower case.
Example : str = “PYTHON language”
Here the string “PYTHON language” is converted to lower case irrespective of the current case.
3.Upper() : Converts the complete string into upper case.
Example : str = “python langUAGE”
Here the string “Python language” is converted to upper case irrespective of the current case.
4.Replace() : Replace method will replace the existing text with the new text as specified.
Example : a = “sam1234sam4321”
Here the string “sam1234sam4321” is converting the “sam” text occurence to “John” in the string.
5.Isdigit() : Isdigit method will return true, if the string contains numbers or else will return false.
Example : c = “293944”
Here is the string c contains only numbers the output will be true or else the output will be false.
6.Isalpha() : isalpha method will return true, if the string contains only alphabets without spaces and digits.
Example : d = “abcd”
e = “My name is”
First example will return true and second example will return false.