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 any()
Python Shallow Copy and Deep Copy
Python 3 for Absolute Beginners - Tim Hall & J.P Stacey
Python Program to Get the Last Element of the List
Python compile()
Python ord()
Python String join()
Python format()
Python locals()
Python Program to Make a Flattened List from Nested List
Jackson – Marshall String to JsonNode
Python Multiple Inheritance
Python Program to Find Numbers Divisible by Another Number
Python delattr()
Python Program to Solve Quadratic Equation
Python Program to Check if a Number is Positive, Negative or 0
Python String rindex()
Python Program to Parse a String to a Float or Int
Count Occurrences of a Char in a String
Python Global Keyword
Python Program to Create a Long Multiline String
Python staticmethod()
Python String isalpha()
Python Dictionary setdefault()
Python Set copy()
Python Program to Print all Prime Numbers in an Interval
Python String casefold()
Python Program to Find Sum of Natural Numbers Using Recursion
Python Program to Print Hello world!
Python issubclass()
Python Program to Trim Whitespace From a String
Python Program to Check Armstrong Number