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 Remove Punctuations From a String
Python datetime
Python Program to Print Output Without a Newline
Java Program to Permute All Letters of an Input String
Python Program to Count the Number of Each Vowel
Python repr()
Python Program to Measure the Elapsed Time in Python
Python Program to Slice Lists
Python Program to Create a Long Multiline String
Python Data Types
Python globals()
Python Modules
Python range()
Python Exception Handling Using try, except and finally statement
Python input()
Python chr()
Python pass statement
Python String ljust()
Encode a String to UTF-8 in Java
Python Program to Check Leap Year
Python Program to Find ASCII Value of Character
Python String count()
Python Program to Find Armstrong Number in an Interval
Python String istitle()
Most commonly used String methods in Java
Python Program to Merge Mails
Python Program to Sort a Dictionary by Value
Python Program to Convert Kilometers to Miles
Python Multiple Inheritance
Python property()
Python Program to Shuffle Deck of Cards
Python all()