-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSecret Code Language (1).py
60 lines (55 loc) · 1.21 KB
/
Secret Code Language (1).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
import random
random.random()
cho = input("want code or decode message:-")
if cho == "code":
try:
a = input("Enter a message:-")
except:
if len(a) < 2:
raise ValueError("len should atleast 3 cher")
if len(a) >= 2:
b = a[1:] + a[0]
c = [
"srk",
"joj",
"yup",
"kok",
"uri",
"xyz",
"jio",
"pok",
"lmn",
"qwe",
"ert",
"frt",
]
d = [
"fop",
"zip",
"mop",
"kai",
"sip",
"uih",
"jui",
"zyx",
"qrs",
"frg",
"khi",
"wer",
]
e = random.choice(c)
f = random.choice(d)
g = e + b + f
h = g.split()
print("Your coded message is:- ", g)
elif cho == "decode":
a1 = input("Enter a code word ")
if len(a1) < 2:
b2 = a1.split()
print("Your Decode word are:-", b2)
else:
c1 = a1[3:-3]
d1 = c1[-1] + c1[:-1]
print(d1)
else:
raise ValueError("Invalid choice and input, pleasecorrect them!!")