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:
Count Occurrences of a Char in a String
Python Program to Display Fibonacci Sequence Using Recursion
Python pow()
Python Dictionary update()
Python Program to Print Output Without a Newline
Python Program to Get the Last Element of the List
Python abs()
Python ord()
Python Program to Find the Sum of Natural Numbers
Python Dictionary values()
Python enumerate()
Python List remove()
Python Set copy()
Java String to InputStream
Python Program to Remove Punctuations From a String
Python dict()
Python String lower()
Python Set pop()
Python bytearray()
Statistical Methods for Machine Learning - Disconver how to Transform data into Knowledge with Pytho...
Python Dictionary items()
Python Set issubset()
Python List extend()
Python strptime()
Python Dictionary
Python File I/O Operation
Python String title()
Python String strip()
Python Program to Slice Lists
Python Program to Find the Factors of a Number
Java InputStream to String
Python max()