Home »
Python
Python String | isupper() and islower() Methods with Examples
Python String | isupper() and islower() Methods with Examples, these are the in-built methods in Python, which are used to check whether a string is in Uppercase or Lowercase.
Submitted by IncludeHelp, on July 18, 2018
isupper() and islower() both are the in- built methods in Python which works with the strings.
1) String isupper() Method
isupper() returns "true" if all characters of the string are uppercase character.
Syntax:
String.isupper()
Parameter: None
Return type:
- true - if all characters of the string are uppercase characters.
- false - if any of the characters is not in uppercase character.
Example:
# str1 with all uppercase characters
str1 = "GOOGLE"
print str1.isupper()
# str2 with uppercase character, DOT, SPACE
str2 = "GOOGLE.COM"
print str2.isupper()
# str3 with uppercase and lowercase characters
str3 ="GOOGLE.com"
print str3.isupper()
# str4 with all lowercase characters
str4 = "google.com"
print str4.isupper()
Output
True
True
False
False
2) String islower() Method
islower() returns "true" if all characters of the string are lowercase character.
Syntax:
String.islower()
Parameter: None
Return type:
- true - if all characters of the string are lowercase characters.
- false - if any of the characters is not in lowercase character.
Example:
# str1 with all lowercase characters
str1 = "google"
print str1.islower()
# str2 with lowercase character, DOT, SPACE
str2 = "google.com"
print str2.islower()
# str3 with lowercase and uppercase characters
str3 ="google.COM"
print str3.islower()
# str4 with all uppercase characters
str4 = "GOOGLE.COM"
print str4.islower()
Output
True
True
False
False