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 List index()
Python Program to Count the Number of Each Vowel
Python Data Types
Python Data Analytics with Pandas, NumPy and Matplotlib - Fabio Nelli
Python Program to Find Numbers Divisible by Another Number
Converting a Stack Trace to a String in Java
Python Program to Count the Occurrence of an Item in a List
Python str()
Count Occurrences of a Char in a String
Python len()
Python String isprintable()
Python map()
Python Operators
Python compile()
Python Deep Learning - Valentino Zocca & Gianmario Spacagna & Daniel Slater & Peter Roelants
Python Program to Add Two Numbers
Deep Learning from Scratch - Building with Python form First Principles - Seth Weidman
Python String isdecimal()
Python List append()
Python hex()
Python Set remove()
Python issubclass()
JavaScript Eval: run a code string
Converting a Stack Trace to a String in Java
Python Program to Print Hello world!
Python Global, Local and Nonlocal variables
Python Dictionary pop()
Python Set symmetric_difference_update()
Python Program to Safely Create a Nested Directory
Python Dictionary get()
Python String isdigit()