This python string tutorial help to learn some string methods(isupper(), islower(), lower() and upper()) with example.These methods are used to check string is uppercase, check string is lowercase, convert string to lowercase and string in uppercase.
String Python methods
We’ll look at the Python functions isupper(), islower(), upper(), and lower(). These are string-handling built-in python methods.
Python isupper()
The isupper() function determines whether or not the argument contains any capital characters. If all of the characters in the string are in upper case, this method returns True; otherwise, False.
Syntax:
string.isupper()
Case 1:
string = 'PYTHONPIP' Output : True
Case 2:
string= 'Pythonpip' Output: False
Python islower()
The islower() function determines whether or not the argument contains any lowercase characters. If all of the characters in the string are in lower case, this method returns True; otherwise, False.
Syntax:
string.islower()
Case 1:
string = 'PYTHONPIP' Output : False
Case 2:
string= 'pythonpip' Output: True
You can also checkout other python String tutorials:
- Python Join List Example
- How To Convert String to int and int to string
- How To Read & Update Excel File Using Python
- Convert Python Dictionary To JSON
lower() – Convert python string to lowercase
The lower() function is used to convert any given string into the lowercase string. All capital characters are converted to lowercase. If no uppercase characters are found, the original string is returned.
Syntax :
string.lower()
Case 1:
string= 'PYTHONPIP' Output: pythonpip
Case 2:
string = 'Pythonpip' Output : pythonpip
upper() – Convert python string to uppercase
The upper()
function is used to convert any given string into the uppercase string. All lowercase characters are converted to uppercase. If no lowercase characters are found, the original string is returned.
Syntax :
string.upper()
Case 1:
string = 'pythonpip' Output: PYTHONPIP
Case 2:
string = 'Pythonpip' Output: PYTHONPIP