Python ProgrammingPython Programming

Check if string is upper, lower, or mixed case in Python

words = ['The', 'quick', 'BROWN', 'Fox',
         'jumped', 'OVER', 'the', 'Lazy', 'DOG']

print([word for word in words if word.islower()])

print([word for word in words if word.isupper()])

print([word for word in words if not word.islower() and not word.isupper()])
Output
['quick', 'jumped', 'the']
['BROWN', 'OVER', 'DOG']
['The', 'Fox', 'Lazy']