isupper(), islower(), lower(), upper() in Python and their applications
Last Updated :
03 May, 2025
Python provides several built-in string methods to work with the case of characters. Among them, isupper(), islower(), upper() and lower() are commonly used for checking or converting character cases. In this article we will learn and explore these methods:
1. isupper() Method
The isupper() method checks whether all the characters in a string are uppercase.
For example:
Input: string = 'GEEKSFORGEEKS'
Output: True
Syntax of isupper()
string.isupper()
Parameters:
- isupper() does not take any parameters
Return Type:
- True if all alphabetic characters are uppercase.
- False otherwise.
Example:
Python
s = 'GEEKSFORGEEKS'
print(s.isupper())
s = 'GeeksforGeeks'
print(s.isupper())
2. islower() Method
The islower() method checks whether all the characters in a string are lowercase.
For example:
Input: string = 'geeksforgeeks'
Output: True
Syntax of islower()
string.islower()
Parameters:
- islower() does not take any parameters
Return Type:
- True if all alphabetic characters are lowercase.
- False otherwise.
Example:
Python
s = 'geeksforgeeks'
print(s.islower())
s = 'GeeksforGeeks'
print(s.islower())
3. lower() Method
The lower() method returns a copy of the string with all uppercase characters converted to lowercase.
For example:
Input: string = 'GEEKSFORGEEKS'
Output: geeksforgeeks
Syntax of lower()
Syntax: string.lower()
Parameters:
- lower() does not take any parameters
Returns: A new string in all lowercase.
Example:
Python
s = 'GEEKSFORGEEKS'
print(s.lower())
s = 'GeeksforGeeks'
print(s.lower())
Outputgeeksforgeeks
geeksforgeeks
Note: Digits and symbols remain unchanged
4. upper() Method
The upper() method returns a copy of the string with all lowercase characters converted to uppercase.
For example:
Input: string = 'geeksforgeeks'
Output: GEEKSFORGEEKS
Syntax of upper()
string.upper()
Parameters:
- upper() does not take any parameters
Returns: A new string in all uppercase.
Example:
Python
s = 'geeksforgeeks'
print(s.upper())
s = 'My name is Prajjwal'
print(s.upper())
OutputGEEKSFORGEEKS
MY NAME IS PRAJJWAL
Application: Count Uppercase, Lowercase Letters and Spaces
In this example we will count the number of uppercase, lowercase and space characters and toggle the case of each character of a string.
Python
s = 'GeeksforGeeks is a computer Science portal for Geeks'
ns = ''
cu = 0
cl = 0
cs = 0
for ch in s:
if ch.isupper():
cu += 1
ns += ch.lower()
elif ch.islower():
cl += 1
ns += ch.upper()
elif ch.isspace():
cs += 1
ns += ch
print("In original String:")
print("Uppercase -", cu)
print("Lowercase -", cl)
print("Spaces -", cs)
print("After changing cases:")
print(ns)
OutputIn original String:
Uppercase - 4
Lowercase - 41
Spaces - 7
After changing cases:
gEEKSFORgEEKS IS A COMPUTER sCIENCE PORTAL FOR gEEKS
Related article:
Similar Reads
isupper() and islower() and their application in C++ In C++, isupper() and islower() are predefined functions used for string and character handling. cstring.h is the header file required for string functions and cctype.h is the headerfile required for character functions. isupper() Function: This function is used to check if the argument contains any
2 min read
Python String Methods - Set 1 (find, rfind, startwith, endwith, islower, isupper, lower, upper, swapcase & title) Some of the string basics have been covered in the below articles:Strings Part-1 Strings Part-2 The important string methods will be discussed in this article1. find("string", beg, end) :- This function is used to find the position of the substring within a string. It takes three arguments:substring
4 min read
numpy string operations | islower() function numpy.core.defchararray.islower(arr) function returns True for each element if all cased characters in the string are lowercase and there is at least one cased character, It returns false otherwise. Parameters: arr : array_like of str or unicode Returns : [ndarray] Output array of bools. Code #1: Py
1 min read
numpy string operations | upper() function numpy.core.defchararray.upper(arr): function is used to return an array with the elements converted to uppercase. Parameters: arr : [ array_like ] Input array which may be str or unicode. Returns : [ndarray] Output uppercased array of str or unicode, depending on input type. Code #1: Python3 # Pytho
1 min read
Python | Pandas Series.str.lower(), upper() and title() Python is a great language for data analysis, primarily because of the fantastic ecosystem of data-centric Python packages. Pandas is one of those packages, making importing and analyzing data much easier. Python has some inbuilt methods to convert a string into a lower, upper, or Camel case. But th
4 min read