-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththevowelcode.py
More file actions
40 lines (35 loc) · 1.04 KB
/
thevowelcode.py
File metadata and controls
40 lines (35 loc) · 1.04 KB
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
def encode(st):
letterList = list(st)
for i in range(len(letterList)):
if letterList[i] == 'a':
letterList[i] = 1
elif letterList[i] == 'e':
letterList[i] = 2
elif letterList[i] == 'i':
letterList[i] = 3
elif letterList[i] == 'o':
letterList[i] = 4
elif letterList[i] == 'u':
letterList[i] = 5
encode_result = ''
for letter in letterList:
encode_result += str(letter)
return encode_result
def decode(st):
letterList = list(st)
for i in range(len(letterList)):
if letterList[i] == '1':
letterList[i] = 'a'
elif letterList[i] == '2':
letterList[i] = 'e'
elif letterList[i] == '3':
letterList[i] = 'i'
elif letterList[i] == '4':
letterList[i] = 'o'
elif letterList[i] == '5':
letterList[i] = 'u'
encode_result = ''
for letter in letterList:
encode_result += str(letter)
return encode_result
decode('h2ll4')