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 Deep Learning Cookbook - Indra den Bakker
Check If a String Is Numeric in Java
Python Tuple index()
Python Set clear()
Python Program to Compute the Power of a Number
Python Program to Concatenate Two Lists
Python Program to Check If a List is Empty
Deep Learning from Scratch - Building with Python form First Principles - Seth Weidman
Python Matrices and NumPy Arrays
Python abs()
Python Data Types
Python Program to Find All File with .txt Extension Present Inside a Directory
Python Program to Convert Decimal to Binary, Octal and Hexadecimal
Python Program to Convert String to Datetime
Python Dictionary popitem()
Python String isspace()
Python Program to Find the Square Root
Python String startswith()
Machine Learning Mastery with Python - Understand your data, create accurate models and work project...
Python time Module
Python Program to Print the Fibonacci sequence
Python String encode()
Python Program to Check the File Size
Python Dictionary copy()
Python while Loop
Python Exception Handling Using try, except and finally statement
Python Program to Display the multiplication Table
Convert Character Array to String in Java
Convert String to int or Integer in Java
Machine Learning with Python for everyone - Mark E.Fenner
Convert char to String in Java
Python Program to Compute all the Permutation of the String