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 String zfill()
Python Dictionary clear()
Python Program to Make a Flattened List from Nested List
Introduction to Machine Learning with Python - Andreas C.Muller & Sarah Guido
Python Program to Copy a File
Python Type Conversion and Type Casting
Python Namespace and Scope
Python String expandtabs()
Python String index()
Python Set difference()
CharSequence vs. String in Java
Python Program to Display Powers of 2 Using Anonymous Function
Python locals()
Python ascii()
Python String capitalize()
Python @property decorator
Python exec()
Python Program to Shuffle Deck of Cards
Python String partition()
Python Program to Find All File with .txt Extension Present Inside a Directory
Python Program to Find the Size (Resolution) of a Image
Python Program to Merge Mails
Python vars()
Python String isdecimal()
Python Program to Swap Two Variables
String Hashing
Python Errors and Built-in Exceptions
Python Exception Handling Using try, except and finally statement
Convert String to int or Integer in Java
Python String count()
Generate a String
Python Program to Check Armstrong Number