Discussion about this post

User's avatar
Andy Tay's avatar

text = "This Sentence Has Mixed CASE Letters!"

uppercase_count = sum(1 for c in text if c.isupper())

lowercase_count = sum(1 for c in text if c.islower())

print(f"The number of uppercase letters is: {uppercase_count}")

print(f"The number of lowercase letters is: {lowercase_count}")

Expand full comment
Edwin Guerra's avatar

Here my original code: https://pastebin.com/ZVSYuTRj#Mv7VtMhN

Improved code thanks to the code shared by @ANDYTAY1:

text = "This Sentence Has Mixed CASE Letters!"

count_upper = sum([1 for character in text if character.isupper()])

count_lower = sum([1 for character in text if character.islower()])

print (f"The text contain {count_upper} uppercase and {count_lower} lowercase letters.")

Expand full comment
4 more comments...

No posts