Python String Case Check: isupper() & islower() Methods

You can use the isupper() and islower() methods to determine if a string is all uppercase or lowercase letters. For example:

s = "HELLO"
if s.isupper():
    print("字符串全为大写字母")
else:
    print("字符串不全为大写字母")

s = "hello"
if s.islower():
    print("字符串全为小写字母")
else:
    print("字符串不全为小写字母")

The above code will output:

字符串全为大写字母
字符串全为小写字母
bannerAds