← Go Back

How to Check if a String Is All Uppercase or Lowercase

The isupper() string method returns true only if all letters in the string are uppercase, and islower() only if all letters are lowercase.

>>> a = "UPPERCASE"
>>> b = "lowercase"
>>> c = "MiXeD"
>>> a.isupper()
True
>>> a.islower()
False
>>> b.isupper()
False
>>> b.islower()
True
>>> c.isupper()
False
>>> c.islower()
False
>>>

If the string has no letters, both methods return false:

>>> "!ยท$%&/)-123".isupper()
False


strings


๐Ÿ You might also find interesting: