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 Strings
Python Dictionary
Python divmod()
Python Program to Print the Fibonacci sequence
Python Program to Get Line Count of a File
Python String lower()
Python print()
Python Set intersection_update()
Python String split()
Python if...else Statement
Python Errors and Built-in Exceptions
Converting a Stack Trace to a String in Java
Python Dictionary fromkeys()
Python list()
Python while Loop
Python Dictionary update()
Python String translate()
Python Program to Parse a String to a Float or Int
Python String strip()
Python classmethod()
Python Set symmetric_difference_update()
Applied Text Analysis with Python - Benjamin Benfort & Rebecca Bibro & Tony Ojeda
Python Program to Check if a Key is Already Present in a Dictionary
Python bool()
Python Program to Get the Last Element of the List
Python Program to Merge Mails
Python Machine Learning Eqution Reference - Sebastian Raschka
Python Program to Merge Two Dictionaries
Python Program to Create a Long Multiline String
Python type()
Python Exception Handling Using try, except and finally statement
Python Program to Get the File Name From the File Path