forked from Biswas026/Mini-projects
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSecret language.py
50 lines (40 loc) · 1.17 KB
/
Secret language.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
def coder():
import random
i = input("ENTER YOUR MESSAGE")
1
words=i.split(" ")
for word in words:
pre = ""
post = ""
if len(word)<3:
print(word[::-1],end=" ")
else:
for j in range(0,3):
pre=pre + (random.choice(alpha))
word=word[1:]+word[0]
for j in range(0,3):
post = post + (random.choice(alpha))
print(pre+word+post,end=" ")
def decode():
i=input("ENTER THE ENCODED MESSAGE")
words=i.split(" ")
for word in words:
if len(word)<3:
print(word[::-1],end=" ")
else:
word=word[3:len(word)-3]
word=word[-1]+word[:len(word)-1]
print(word,end=" ")
print("WHAT DO YOU WANTED TO DO?")
print("1.ENCODE 2.DECODE 3.QUIT")
while(True):
choice=int(input("\nENTER YOUR CHOICE"))
if choice==1:
coder()
elif choice==2:
decode()
elif choice==3:
break;
else:
raise ValueError("SORRY YOU HAVE ENTERED THE WRONG VALUE")
print("THANK YOU FOR USING OUR MESSAGING SERVICE")