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 help()
Python Program to Convert Bytes to a String
Python Program to Safely Create a Nested Directory
Python Program to Remove Duplicate Element From a List
Python Program to Differentiate Between del, remove, and pop on a List
Python Program to Slice Lists
Python Set clear()
Deep Learning with Python - A Hands-on Introduction - Nikhil Ketkar
Python Program to Copy a File
Python Data Types
Java – Generate Random String
Python Statement, Indentation and Comments
Python Tuple count()
Python Custom Exceptions
Python Artificial Intelligence Project for Beginners - Joshua Eckroth
Python String zfill()
Python Set symmetric_difference()
Converting String to Stream of chars
Java String to InputStream
Python Set pop()
Python List reverse()
Python String strip()
Python String find()
Python del Statement
Python Program to Get the Last Element of the List
Format ZonedDateTime to String
Map to String Conversion in Java
Building Chatbots with Python Using Natural Language Processing and Machine Learning - Sumit Raj
How to Remove the Last Character of a String?
Python String istitle()
Python Dictionary update()
Python Dictionary setdefault()