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:
Converting String to Stream of chars
Python Machine Learning Third Edition - Sebastian Raschka & Vahid Mirjalili
Deep Learning from Scratch - Building with Python form First Principles - Seth Weidman
Python Modules
Python Deeper Insights into Machine Learning - Sebastian Raschka & David Julian & John Hearty
Python type()
Python String strip()
Python Program to Find the Factors of a Number
Python Program to Display the multiplication Table
Python Machine Learning - Sebastian Raschka
Python Set intersection_update()
Convert char to String in Java
Python Program to Get the File Name From the File Path
Python Iterators
Python String lower()
Python Program to Add Two Matrices
Adding a Newline Character to a String in Java
Python Program to Check Armstrong Number
Introduction to Machine Learning with Python - Andreas C.Muller & Sarah Guido
How to Remove the Last Character of a String?
Python String find()
Python set()
Python Program to Append to a File
Python String maketrans()
Python List append()
Python eval()
Python Program to Get a Substring of a String
Python getattr()
Case-Insensitive String Matching in Java
Python round()
Python pow()
Python Program to Check Leap Year