Level 3: Real-World
import string
text = "Edu3cation is a power123ful tool for improving our under2standing of the uni45verse. !"
vowels = "aeiouAEIOU"
counts = {'vowels': 0, 'consonants': 0, 'numbers': 0, 'punctuation': 0}
for x in text:
if x.isalpha():
if x in vowels:
counts['vowels'] += 1
else:
counts['consonants'] += 1
elif x.isnumeric():
counts['numbers'] += 1
elif x in string.punctuation:
counts['punctuation'] += 1
total = sum(counts.values())
print(f'Total characters: {total}')
print(f"Total count of vowel characters: {counts['vowels']}")
print(f"Total count of consonant characters: {counts['consonants']}")
print(f"Total count of numbers: {counts['numbers']}")
print(f"Total count of punctuation: {counts['punctuation']}")
import string
text = "Edu3cation is a power123ful tool for improving our under2standing of the uni45verse. !"
vowels = "aeiouAEIOU"
counts = {'vowels': 0, 'consonants': 0, 'numbers': 0, 'punctuation': 0}
for x in text:
if x.isalpha():
if x in vowels:
counts['vowels'] += 1
else:
counts['consonants'] += 1
elif x.isnumeric():
counts['numbers'] += 1
elif x in string.punctuation:
counts['punctuation'] += 1
total = sum(counts.values())
print(f'Total characters: {total}')
print(f"Total count of vowel characters: {counts['vowels']}")
print(f"Total count of consonant characters: {counts['consonants']}")
print(f"Total count of numbers: {counts['numbers']}")
print(f"Total count of punctuation: {counts['punctuation']}")