Quick actions

cmd+k|ctrl+k

Navigation

Languages

02 - Ex 03

Snippet info

Language

Python

Visibility

public

Author

vovanthinh2312

Created

2016-10-20T09:52:56Z

Updated

2016-10-20T12:02:17Z

#Đếm số nguyên âm, số phụ âm trong 1 string.
s = 'asfasfhBAS734@o&*#'
vowels = 'ueoai'
consonants = 'qwrtypsdfghjklzxcvbnm'
s = s.lower()
a = 0
# a: The number of vowels
b = 0
# b: The number of consonants
for w in s:
    if w in vowels:
        a += 1
    elif w in consonants:
        b += 1
print('The number of vowels = {0}\nThe number of consonants = {1}'.format(a,b))

INFO