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 Program to Append to a File
Python List clear()
Python Global, Local and Nonlocal variables
Python sorted()
Python Program to Swap Two Variables
Python Program to Count the Occurrence of an Item in a List
Python Machine Learning Cookbook - Practical solutions from preprocessing to Deep Learning - Chris A...
JavaScript Eval: run a code string
Python Program to Differentiate Between del, remove, and pop on a List
Python max()
Python hasattr()
Python if...else Statement
Python Directory and Files Management
Map to String Conversion in Java
Learning scikit-learn Machine Learning in Python - Raul Garreta & Guillermo Moncecchi
Python Program to Find Numbers Divisible by Another Number
Python memoryview()
Python Dictionary update()
Python Program to Compute all the Permutation of the String
Python Program to Shuffle Deck of Cards
Python Program to Multiply Two Matrices
Python Errors and Built-in Exceptions
Converting a Stack Trace to a String in Java
Python open()
APIs in Node.js vs Python - A Comparison
How to get current date and time in Python?
Java – String to Reader
Python Program to Extract Extension From the File Name
Python Program to Count the Number of Occurrence of a Character in String
Python Tuple index()
Converting a Stack Trace to a String in Java
Python bool()