Python isupper() method



Python isupper() method

 

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”.
This function is used to check if the argument contains any uppercase characters such as :

ABCDEFGHIJKLMNOPQRSTUVWXYZ

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.

Examples:

 

 

Input : string = 'GEEKSFORGEEKS'
Output : True

Input : string = 'GeeksforGeeks'
Output : False

Errors And Exceptions

  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”
# Python code for implementation of isupper()
 
# checking for uppercase characters
string = 'GEEKSFORGEEKS'
print(string.isupper())
 
string = 'GeeksforGeeks'
print(string.isupper())

Output:

True
False

Last Updated on July 24, 2021 by admin

Leave a Reply

Your email address will not be published. Required fields are marked *

Recommended Blogs