English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Python basic tutorial

Python flow control

Python Functions

Python Data Types

Python file operations

Python objects and classes

Python date and time

Advanced knowledge of Python

Python reference manual

Python string isupper() usage and example

Python string methods

The isupper() method of the string returns whether all characters in the string are uppercase.

The syntax of the isupper() method is:

string.isupper()

String isupper() parameter

The isupper() method does not take any parameters.

From the isupper() return value of the string 

The isupper() method returns:

  • True If all characters in the string are uppercase

  • False If any character in the string is lowercase

Example1isupper() return value

# empty string
string = "THIS IS GOOD!"
print(string.isupper());
# Replace letters with numbers
string = "THIS IS ALSO G00D!"
print(string.isupper());
# lowercase string
string = "THIS IS not GOOD!"
print(string.isupper());

When running the program, the output is:

True
True
False

Example2How to use isupper() in the program?

string = 'THIS IS GOOD'
if string.isupper() == True:
  print('Does not contain lowercase letters.')
else:
  print('Contains lowercase letters.')
  
string = 'THIS IS gOOD'
if string.isupper() == True:
  print('Does not contain lowercase letters.')
else:
  print('Contains lowercase letters.')

When running the program, the output is:

Does not contain lowercase letters.
Contains lowercase letters.

Python string methods