What is isupper() in Python?

In Python, isupper() is a built-in method used for string handling. This method returns “True” if all characters in the string are uppercase, otherwise, returns “False”

  1. It returns “True” for whitespaces but if there is only whitespace in the string then returns “False”.
  2. It does not take any arguments, Therefore, It returns an error if a parameter is passed.
  3. Digits and symbols return “True” but if the string contains only digits and numbers then returns “False”

This function is used to check if the argument contains any uppercase characters such as:

Input: string = 'w3wiki'
Output: True

Syntax of isupper()

Syntax: string.isupper() 

Parameters: 

  • isupper() does not take any parameters 

Returns: True- If all characters in the string are uppercase. False- If the string contains 1 or more non-uppercase characters.

Example: Checking for Uppercase Characters

In this code string variable contain value “w3wiki” . String consist of only uppercase letters. When this call the “isupper”method on string , It will return “True” and when it checks the other string “w3wiki” that is mix of upper and lower string it will return “False“.

Python3




string = 'w3wiki' # Define a string containing only uppercase letters
print(string.isupper())  # Check if all characters in the string are uppercase and print the result
  
string = 'w3wiki'# Define a string with a mix of uppercase and lowercase letters
print(string.isupper()) # Check if all characters in the string are uppercase and print the result


Output:

True
False

isupper(), islower(), lower(), upper() in Python and their applications

In this article, we will discuss isupper(), islower(), upper(), and lower() functions in Python. These methods are built-in methods used for handling strings. Before studying isupper(), islower(), upper(), and lower() in detail let’s get a basic idea about them.

Similar Reads

What is isupper() in Python?

In Python, isupper() is a built-in method used for string handling. This method returns “True” if all characters in the string are uppercase, otherwise, returns “False”....

What is islower() in Python?

...

What is lower() in Python?

In Python, islower() is a built-in method used for string handling. The islower() method returns True if all characters in the string are lowercase, otherwise, returns “False”....

What is upper() in Python?

...

Count uppercase, lowercase letters, and spaces

In Python, lower() is a built-in method used for string handling. The lower() method returns the lowercased string from the given string. It converts all uppercase characters to lowercase python. If no uppercase characters exist, it returns the original string....