-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMubashir_Cipher.py
More file actions
41 lines (31 loc) · 987 Bytes
/
Mubashir_Cipher.py
File metadata and controls
41 lines (31 loc) · 987 Bytes
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
''' Write a function to implement Mubashir cipher .
- The Mubashir Cipher takes a string and replaces each letter with the letter that
is directly opposite it in the English alphabet. Hint: In English alphabet, 'a' is opposite
to 'z', 'b' is opposite to 'y', 'c' is opposite to 'x', and so on. The same rule applies for
uppercase letters.
Input :'abc'
Output : 'zyx'
Reason : In English alphabet, 'a' is opposite to 'z', 'b' is opposite to 'y',
and 'c' is opposite to 'x'. So, when we apply Mubashir Cipher on 'abc', we get 'zyx.
Input :'mubashir'
Output : 'nfyzhsri'
Input : 'cipher'
Output : 'xrksvi'
Input : 'hello world'
Output : 'svool dliow'
'''
# a - 97 , z - 122
def mubashir_cipher(text):
new =''
max=122
for i in text:
if i==' ':
new+=" "
else:
current = ord(i)
change = max - current
print(change + 97)
new+=chr(change + 97)
print(new)
return new
mubashir_cipher('abc')