-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathletterfilter.py
46 lines (27 loc) · 862 Bytes
/
letterfilter.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
class LetterFilter:
def __init__(self, s):
self.s = s
def filter_vowels(self):
#create a list of vowels
vowels=['a','e','i','o','u']
string=''
for ch in self:
#every consonant in given string i.e self is concatinated to string
if ch not in vowels:
string=string+ch
self=string
return self
def filter_consonants(self):
#create a list of vowels
vowels=['a','e','i','o','u']
string=''
for ch in self:
#every vowel in given string i.e self is concatinated to string
if ch in vowels:
string=string+ch
self=string
return self
s = input("Please enter the message:\n")
f = LetterFilter(s)
print(f'processing out consonants from input\n', filter_consonants(s))
print(f'processing out vowels from input\n', filter_vowels(s))