-
Notifications
You must be signed in to change notification settings - Fork 1
/
TCSNQT_VowelCountandReplace.py
71 lines (44 loc) · 1.04 KB
/
TCSNQT_VowelCountandReplace.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
def checkNumeric(text):
numtext = "0123456789"
for num in numtext:
if num in text:
return True
return False
def vowelCount(text):
vowel_dict = {}
vowel_dict['a'] = 0
vowel_dict['e'] = 0
vowel_dict['i'] = 0
vowel_dict['o'] = 0
vowel_dict['u'] = 0
flag = False;
for c in text:
if c in vowel_dict:
vowel_dict[c] += 1
flag = True
return flag, vowel_dict
if __name__ == "__main__":
text = input()
# if it is blank:
# print Invalid input
text = text.strip()
if len(text) < 1:
print("INVALID INPUT")
elif checkNumeric(text):
# if it contains any numeric value
# print 0
print("0")
else:
flag, vowel_dict = vowelCount(text)
if flag:
# now print the count of vowels
for item in vowel_dict:
print(item, ":", vowel_dict[item])
# print the message without vowel
for c in 'aeiou':
text = text.replace(c, '')
print(text)
else:
# if it contains no vowel
# print 0
print("0")