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:
Natural Language Processing with Python - Steven Bird & Ewan Klein & Edward Loper
Python eval()
Python Program to Check if a Number is Odd or Even
Python Data Structures and Algorithms - Benjamin Baka
Python Program to Print the Fibonacci sequence
Python String endswith()
Python delattr()
Python String find()
Python Set issuperset()
Python Objects and Classes
Python Global Keyword
Python Program to Check If a String Is a Number (Float)
Python isinstance()
Python Program to Safely Create a Nested Directory
Python String isdecimal()
Python Program to Multiply Two Matrices
Python datetime
Python Program to Check If a List is Empty
Deep Learning from Scratch - Building with Python form First Principles - Seth Weidman
Python abs()
Deep Learning with Python - Francois Chollet
Python List index()
Deep Learning with Applications Using Python - Navin Kumar Manaswi
Python str()
JavaScript Eval: run a code string
Python iter()
Check If a String Is Numeric in Java
Python Program to Count the Number of Digits Present In a Number
Python List remove()
Python hash()
Python File I/O Operation
Python Iterators