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 String isnumeric()
Python Set issuperset()
Python sorted()
Python Program to Catch Multiple Exceptions in One Line
Python Program to Display the multiplication Table
Python String isalnum()
Python dir()
Python Inheritance
Python del Statement
Python Program to Represent enum
Python chr()
Python String upper()
Python Dictionary values()
Python strptime()
Python hash()
Python Program to Parse a String to a Float or Int
Python Program Read a File Line by Line Into a List
Python Program to Access Index of a List Using for Loop
Python callable()
Python Program to Find the Factors of a Number
Python Program to Sort Words in Alphabetic Order
String Hashing
Python Dictionary copy()
Python Program to Check if a Number is Odd or Even
Python Function Arguments
Python frozenset()
Most commonly used String methods in Java
Python Package
Python Program to Multiply Two Matrices
Java – Generate Random String
Python List pop()
Java – String to Reader