Python String isupper() Method
The isupper() function checks if the characters in a string are uppercase. If the characters in the string are uppercase, it will return the boolean value True. Otherwise, it will return the boolean value False.
The way it is written is like this:
string.isupper ()
Parameters: The isupper() function does not take any parameters.
return value:
True: If the characters in the string are uppercase.
False: If the string contains one or more non-uppercase characters.
Errors and exceptions:
If a parameter is passed to the isupper() function, an error occurs
Example:
# Define a variable composed of uppercase letters
string = "LEARN PYTHON WITH AHMED OBAID"
#isupper function call
result = string. isupper() # returns True
# Print the result
print(result)
# Define a variable composed of lowercase and uppercase letters
string = "Learn Python with Ahmed Obaid"
#isupper function call
result = string. isupper() # returns False
# Print the result
print(result)
# Define a variable made up of lowercase letters
string = "learn python with ahmed obaid"
#isupper function call
result = string. isupper() # returns False
#undefined Print the result
print(result)
The output will be:
True
False
False
The isupper() function always returns the boolean value True. If the string contains uppercase letters, numbers and symbols.
Example:
# Define a variable consisting of uppercase letters, numbers and symbols
string = "@Ahmed Obaid 2023"
#isupper function call
result = string. isupper() # returns True
# Print the result
print(result)
The output will be:
True
The isupper() function always returns a boolean False if the string contains only numbers and symbols. Without capital letters.
Example:
# Define a variable consisting of numbers and symbols
string = "100$"
#isupper function call
result = string. isupper() # returns False
# Print the result
print(result)
The output will be:
False
External sources:
Built-in functions - official Python documentation
If you have any questions or concerns, leave them in the comments
Tags
Python python data types Python String string methods python python string isupper method
Share page
About author
Ahmed Obaid
Hello, I am Ahmed Obaid, an Egyptian Arabic programmer. I would like to put my experiences learning Python on this site So that it will be a reference for you and me as well.
Sign up to leave a comment