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 __import__()
Python Program to Transpose a Matrix
Python Tuple index()
Python Matrices and NumPy Arrays
Python String join()
Python Program to Check Whether a String is Palindrome or Not
Python String rpartition()
Deep Learning with Applications Using Python - Navin Kumar Manaswi
Python String upper()
Python Program to Represent enum
Python Program to Get the Last Element of the List
Python vars()
Python String isprintable()
Natural Language Processing with Python - Steven Bird & Ewan Klein & Edward Loper
Python Operators
Python Sets
Python Program to Print Colored Text to the Terminal
Python ascii()
Python List
Machine Learning Mastery with Python - Understand your data, create accurate models and work project...
Java Program to Permute All Letters of an Input String
Python Data Structures and Algorithms - Benjamin Baka
Python frozenset()
How to Get Started With Python?
Python Closures
Python String capitalize()
Python slice()
Python Program to Create a Countdown Timer
Python Set discard()
Python pow()
Python Iterators
Python Operator Overloading