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:
Intelligent Projects Using Python - Santanu Pattanayak
Python Program to Find the Factors of a Number
Python Program to Compute all the Permutation of the String
Python Program to Append to a File
Python issubclass()
String Initialization in Java
Python Set remove()
Java InputStream to String
Python strptime()
Array to String Conversions
Python Exception Handling Using try, except and finally statement
Python String title()
Python for Programmers with introductory AI case studies - Paul Deitel & Harvey Deitel
How to Remove the Last Character of a String?
Python Program to Get the Class Name of an Instance
Python List append()
Python dir()
Python Program to Merge Two Dictionaries
Python RegEx
Python len()
Python Set add()
Python List index()
Python time Module
Python Machine Learning Cookbook - Practical solutions from preprocessing to Deep Learning - Chris A...
Python Dictionary items()
Python String casefold()
Python filter()
Python bool()
Python Program to Access Index of a List Using for Loop
Python setattr()
Python Closures
Python format()