-
Notifications
You must be signed in to change notification settings - Fork 0
/
lab6_encoder.py
36 lines (30 loc) · 904 Bytes
/
lab6_encoder.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
def encoder(password):
encoded_password = ''
for i in range(len(password)):
password_integer = int(password[i]) + 3
encoded_password += str(password_integer)[-1]
return encoded_password
def decode(password):
decoded = ''
for digit in password:
decoded_digit = (str(int(digit) - 3) % 10)
decoded += decoded_digit
return decoded
def main():
while True:
print('Menu')
print('-' * 9)
print('1. Encode')
print('2. Decode')
print('3. Quit')
print()
choice = int(input('Do you want to encode, decode or quit? '))
if choice == 1:
password = input('What is your password? ')
print(encoder(password))
elif choice == 2:
print('This is for the other person ')
elif choice == 3:
break
if __name__ == '__main__':
main()