-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlab.py
34 lines (31 loc) · 1.08 KB
/
lab.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
def main():
print("Menu")
print("-" * 13)
print("1. Encode \n2. Decode \n3. Quit")
def encode(number):
coded_pass = []
number_list =number.split() # split password entered as a list
for num in num_list:
coded_pass += num+3 # encode numbers by multiplying by 3
coded = "".join(coded_pass) # return list to a string
return coded
def decode(number):
number_list = number.split()
for num in num_list:
decoded_pass += num-3
decoded = "".join(decoded_pass)
return decoded
if __name__ == "__main__":
condition = True
while condition == True:
main()
choice = int(input("Please enter an option: "))
if choice == 1:
new_number = encode(input("Please enter your password to encode:"))
print("Your password has been encoded and stored!")
print(new_number)
elif choice == 2:
numberDecode = decode(coded)
print(f"The encoded password is {new_number}, and the original password is {numberDecode}")
elif choice == 3:
condition = False