Python String isupper() Method

The isupper() method is a string method that returns True if all the characters in a string are uppercase, otherwise False. It also returns False if the string contains no alphabets.

Here are some examples of using the isupper() method:

# example 1: check if a string is all uppercase
string = "HELLO WORLD"
print(string.isupper()) # True


# example 2: check if a string with symbols and numbers is all uppercase
string = "PYTHON IS #1"
print(string.isupper()) # True


# example 3: check if a string with lowercase characters is all uppercase
string = "Hello World"
print(string.isupper()) # False


# example 4: check if a string with no alphabets is all uppercase
string = "#1?><~ ()+=*-+./\\ []"
print(string.isupper()) # False

If you have any questions about this code, you can drop a line in comment.

Comments

Popular posts from this blog

Python chr() Built in Function

Python float() Built in Function

Python bool() Built in Function

Python Printing Readable Results

Python exec() Built in Function