Last active
November 28, 2020 14:14
-
-
Save pavi2410/6efddc55ea2e6528d00de158d8df7fa6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
file = open("lorem.txt", "r") | |
text = file.read() | |
v = 0 | |
c = 0 | |
u = 0 | |
l = 0 | |
for char in text: | |
if char.lower() in "aeiou": # this will match char against { a e i o u } and { A E I O U } because char is converted to lowercase | |
v += 1 | |
else: # else this is a consonant | |
c += 1 | |
if char.isupper(): # test whether the char is upper | |
u += 1 | |
else: # or lower | |
l += 1 | |
file.close() | |
print("Vowels =", v) | |
print("Consonants =", c) | |
print("Lowercase letters =", l) | |
print("Uppercase letters =", u) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment