String Methods

Python provides a set of built-in methods that we can use to alter and modify the strings.

 

upper() : The upper() method converts a string to upper case.

Example:

str1 = "AbcDEfghIJ"
print(str1.upper())
Output:
ABCDEFGHIJ
lower() : The lower() method converts a string to upper case.

Example:

str1 = "AbcDEfghIJ"
print(str1.lower())
Output:
abcdefghij
isalpha() :It will check all elements of a string should be text only so that you will get ot True otherwise False.

Example 1:

string='abc23'
string2="hello"
string3="12345"
print(string.isalpha())  # it only check alphabet
print(string2.isalpha())
print(string3.isalpha())
Output:
False
True
False
islower() : The islower() method returns True if all the characters in the string are lower case, else it returns False. 

Example 1:

s3="lokesj"
print(s3.islower())
Output:
True