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 isinstance()
Python eval()
Python locals()
How to Get Started With Python?
Python Set union()
Python List
Python Program to Measure the Elapsed Time in Python
Python Program to Get the Class Name of an Instance
Python bytes()
Python Program to Find the Square Root
Python Program to Iterate Over Dictionaries Using for Loop
Python issubclass()
Python Program to Trim Whitespace From a String
Python Program to Check if a Number is Odd or Even
Python String strip()
Python String capitalize()
Python Program to Concatenate Two Lists
Python String splitlines()
Python Program to Append to a File
Python set()
Python Program to Create a Long Multiline String
Case-Insensitive String Matching in Java
Python filter()
Python repr()
Python Program to Find Armstrong Number in an Interval
Python float()
Python setattr()
Python Program to Compute all the Permutation of the String
Python for Loop
Python Program to Get a Substring of a String
Python datetime
Statistical Methods for Machine Learning - Disconver how to Transform data into Knowledge with Pytho...