-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshrift_code_2.py
More file actions
35 lines (35 loc) · 1.15 KB
/
Copy pathshrift_code_2.py
File metadata and controls
35 lines (35 loc) · 1.15 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
alphabet = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"
isWork = True
while isWork:
print('1) Make a code\n2) Decode a message\n3) Quit')
choice = int(input('Enter your selection: '))
if choice == 1:
txt = input('Enter your message: ')
num = int(input('Enter a number (1-26): '))
txt_low = txt.lower()
mess = ''
for letter in txt_low:
position = alphabet.find(letter)
new_position = position + num
if letter in alphabet:
mess = mess + alphabet[new_position]
else:
mess = mess + letter
print(mess)
print('')
elif choice == 2:
txt = input('Enter your message: ')
num = int(input('Enter a number (1-26): '))
txt_low = txt.lower()
mess = ''
for letter in txt_low:
position = alphabet.find(letter)
new_position = position - num
if letter in alphabet:
mess = mess + alphabet[new_position]
else:
mess = mess + letter
print(mess)
print('')
elif choice == 3:
isWork = False