-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.py
65 lines (56 loc) · 1.12 KB
/
script.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
option = input()
msg=input('Enter message : ')
key=input('Enter key : ')
if(len(key)<len(msg)):
new_key = key*len(msg)
new_key = new_key[0:len(msg)]
arr = {0:['A','a'],
1:['B','b'],
2:['C','c'],
3:['D','d'],
4:['E','e'],
5:['F','f'],
6:['G','g'],
7:['H','h'],
8:['I','i'],
9:['J','j'],
10:['K','k'],
11:['L','l'],
12:['M','m'],
13:['N','n'],
14:['O','o'],
15:['P','p'],
16:['Q','q'],
17:['R','r'],
18:['S','s'],
19:['T','t'],
20:['U','u'],
21:['V','v'],
22:['W','w'],
23:['X','x'],
24:['Y','y'],
25:['Z','z']
}
l=[]
first_half = 0
second_half = 0
for i in range(0, len(msg)):
for key, value in arr.items():
if(str(msg[i])==str(value[0]) or str(msg[i])==str(value[1])):
first_half = key
if(str(new_key[i])==str(value[0]) or str(new_key[i])==str(value[1])):
second_half = key
if(option == 'e'):
sum = int(first_half) + int(second_half)
else:
sum = int(first_half) - int(second_half)
if(int(sum)>25):
sum = sum%26
if(int(sum)<0):
sum += 26
l.append(sum)
w=[]
for x in l:
ct = arr.get(x)
w.append(ct[0])
print(w)