In this tutorial, We will see the python string isupper() method with examples.
isupper() Method
The isupper() method is one of the methods in a python string. Python string isupper() method checks all the characters in the string are uppercase alphabets(A-Z).
- Return True, If all the characters in the string are uppercase alphabets.
- Return False, If all the characters in the string are not uppercase alphabets.
Syntax of Python string isupper() method
This is the syntax of the python string isupper() method.
string.isupper()
Example of the Python string isupper() method
#Example 1 text = "python is a programming language" #check the text characters are in Uppercase. print(text.isupper()) #output : False
#Example 2 text = "PYTHON PROGRAMMING" print(text.isupper()) #output: True #Exmaple 3 message = "hello WORLD" msg = message.isupper() print(msg) #output: False
# Example 4 message = "HELLO 123 @" #contain number and special characters with Uppercase alphabets. msg = message.isupper() print(msg) #output: True text = "123 @" #contain only number and special characters. msg = message.isupper() print(msg) #output: False
Related Programs
- Take a string from the user and check characters in uppercase or not.
message = input("Enter the message") msg = message.isupper() print(msg)
- Take a string from the user and check the particular string in uppercase or in lowercase. if string characters are in uppercase, then convert them into lowercase, and if string characters are in lowercase, then convert them into uppercase.
message = input("Enter the message ") if(message.isupper()): print(message.lower()) else: print(message.upper())
Related Posts
- isalpha() Method in Python
- isalnum() Method in Python
- isdigit() Method in Python
- islower() method in Python