Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

isupper
string
python
communitycreator

What is string.isupper in Python?

Programming Bytes

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

The isupper method will return True if all the alphabetical characters present in the string are in uppercase. If any character of the string is in lowercase, or no alphabetical character is present in the string, then False is returned.

Syntax

string.isupper()

Return value

True:

  • If all the characters of the string are uppercase.

False in any one of the below cases:

  • If any character of the string is lowercase.

  • If no alphabetical character is present in the string.

# True - because all characters are lowercase
string = 'ALL UPPER';
print(string.isupper())
# False - because string has lowercase character - r
string = 'LOWEr';
print(string.isupper())
# False - because no alphabetical character present
string = '10';
print(string.isupper())
# True - because one alphabetical character present and that character is in upper case
string = '12B';
print(string.isupper())
# False - because one alphabetical character present and that character is not lower case
string = '12b';
print(string.isupper())

In the above code, we call the isupper method:

  • For the string ALL UPPER, the isupper will return True because all the characters of the string are uppercase letters.

  • For the string LOWEr, the isupper will return False because the string contains one lowercase letter (r).

  • For the string 10, the isupper will return False because the string contains no alphabetical letter.

  • For the string 12B, the isupper will return True because the string has one alphabetical character and that character is in uppercase.

  • For the string 12b, the isupper will return False because the string has one lowercase character.

RELATED TAGS

isupper
string
python
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring