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

Python Basic Tutorial

Python Flow Control

Fonctions en Python

Types de données en Python

Python File Operations

Python Objects and Classes

Python Date and Time

Advanced Python Knowledge

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()

The isupper() parameter of the string

The isupper() method does not take any parameters.

From the return value of isupper() from the string 

The isupper() method returns:

  • True If all characters in the string are uppercase

  • False If any character in the string is lowercase

Example1The return value of isupper()

# 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());

The output when running the program is:

True
True
False

Example2How to use isupper() in a 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.')

The output when running the program is:

Does not contain lowercase letters.
Contains lowercase letters.

Python string methods