Table of Contents
The string isupper() method returns whether or not all characters in a string are uppercased or not.
The syntax of isupper() method is:
string.isupper()
1. String isupper() Parameters
The isupper() method doesn’t take any parameters.
2. Return value from String isupper()
The isupper() method returns:
- True if all characters in a string are uppercase characters
- False if any characters in a string are lowercase characters
3. Example 1: Return value of isupper()
# example string string = "THIS IS GOOD!" print(string.isupper()); # numbers in place of alphabets string = "THIS IS ALSO G00D!" print(string.isupper()); # lowercase string string = "THIS IS not GOOD!" print(string.isupper());
Output
True True False
4. Example 2: How to use isupper() in a program?
string = 'THIS IS GOOD'
if string.isupper() == True:
print('Does not contain lowercase letter.')
else:
print('Contains lowercase letter.')
string = 'THIS IS gOOD'
if string.isupper() == True:
print('Does not contain lowercase letter.')
else:
print('Contains lowercase letter.')
Output
Does not contain lowercase letter. Contains lowercase letter.
Related posts:
Python Program to Create a Countdown Timer
Python timestamp to datetime and vice-versa
Python len()
Split a String in Java
Python ord()
Python Program to Count the Occurrence of an Item in a List
Python Program to Slice Lists
Python Data Structures and Algorithms - Benjamin Baka
Python hash()
Python Program to Get the Class Name of an Instance
Python any()
Python Program to Find LCM
Python Recursion
Python while Loop
Python Set intersection()
Python Deep Learning Cookbook - Indra den Bakker
Python locals()
Python format()
Python bool()
Most commonly used String methods in Java
Python String capitalize()
Statistical Methods for Machine Learning - Disconver how to Transform data into Knowledge with Pytho...
Python Multiple Inheritance
Python Program to Find the Largest Among Three Numbers
Introduction to Scientific Programming with Python - Joakim Sundnes
Python String format_map()
Node.js vs Python for Backend Development
Python Program to Solve Quadratic Equation
Python dir()
Python Program to Check Armstrong Number
Python list()
Python String isdecimal()