A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/python/isupper-islower-lower-upper-python-applications/ below:

isupper(), islower(), lower(), upper() in Python and their applications

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:

Return Type:

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:

Return Type:

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:

Returns: A new string in all lowercase.

Example:

Python
s = 'GEEKSFORGEEKS'
print(s.lower()) 

s = 'GeeksforGeeks'
print(s.lower()) 

Output
geeksforgeeks
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:

Returns: A new string in all uppercase.

Example:

Python
s = 'geeksforgeeks'
print(s.upper()) 

s = 'My name is Prajjwal'
print(s.upper())

Output
GEEKSFORGEEKS
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)

Output
In original String:
Uppercase - 4
Lowercase - 41
Spaces - 7
After changing cases:
gEEKSFORgEEKS IS A COMPUTER sCIENCE PORTAL FOR gEEKS

Related article:



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4