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 round()
Python Program to Parse a String to a Float or Int
Python Dictionary popitem()
Python Set difference()
String Processing with Apache Commons Lang 3
Python Program to Display Fibonacci Sequence Using Recursion
Python String isalpha()
Converting String to Stream of chars
Python Dictionary setdefault()
Deep Learning with Python - Francois Cholletf
Python Program to Get the Class Name of an Instance
Python Operator Overloading
Python Dictionary copy()
Python Program to Sort a Dictionary by Value
Python break and continue
Python Program to Count the Number of Digits Present In a Number
Python String casefold()
Python min()
Python Closures
Check if a String is a Palindrome in Java
Python Program to Find All File with .txt Extension Present Inside a Directory
Python Objects and Classes
Python Program to Compute the Power of a Number
Python Program to Copy a File
How to Get Started With Python?
Python __import__()
Encode a String to UTF-8 in Java
Python List index()
String Initialization in Java
Python Namespace and Scope
Python Dictionary pop()
Python String expandtabs()