# CHALLENGE 1
def encode(string):
alphabet = "abcdefghijklmnopqrstuvwxyz"
encoded_alpha = "zabcdefghijklmnopqrstuvwxy"
encoded_msg = ""
for letter in message:
if letter == " ":
encoded_msg += " "
else:
index = alphabet.find(letter)
if index == -1:
return False
enc_char = encoded_alpha[index]
encoded_msg += enc_char
print(encoded_msg)
message = input("Enter the string you want encoded: ").lower()
worked = False
while worked == False:
worked = encode(message)
if worked == False:
message = input("Enter the string you want encoded: ").lower()
# CHALLENGE 2
def encode(string):
alphabet = "abcdefghijklmnopqrstuvwxyz"
encoded_alpha = "zabcdefghijklmnopqrstuvwxy"
numbers = "0123456789"
encoded_nums = "9012345678"
encoded_msg = ""
for letter in message:
if letter == " ":
encoded_msg += " "
else:
index = alphabet.find(letter)
if index == -1:
index = numbers.find(letter)
if index == -1:
return False
enc_char = encoded_nums[index]
else:
enc_char = encoded_alpha[index]
encoded_msg += enc_char
print(encoded_msg)
message = input("Enter the string you want encoded: ").lower()
worked = False
while worked == False:
worked = encode(message)
if worked == False:
message = input("Enter the string you want encoded: ").lower()
# CHALLENGE 3
def encode(string):
alphabet = "abcdefghijklmnopqrstuvwxyz"
encoded_alpha = "zabcdefghijklmnopqrstuvwxy"
numbers = "0123456789"
encoded_nums = "9012345678"
specials = ".,!‘?;: “&#@$%^*()/\[]{}|-_+=~"
encoded_specials = "~.,!‘?;: “&#@$%^*()/\[]{}|-_+="
encoded_msg = ""
for letter in message:
index = specials.find(letter)
if index == -1:
index = alphabet.find(letter)
if index == -1:
index = numbers.find(letter)
if index == -1:
return False
enc_char = encoded_nums[index]
else:
enc_char = encoded_alpha[index]
else:
enc_char = encoded_specials[index]
encoded_msg += enc_char
print(encoded_msg)
message = input("Enter the string you want encoded: ").lower()
worked = False
while worked == False:
worked = encode(message)
if worked == False:
message = input("Enter the string you want encoded: ").lower()
# CHALLENGE 5
def decode(string):
alphabet = "abcdefghijklmnopqrstuvwxyz"
encoded_alpha = "zabcdefghijklmnopqrstuvwxy"
translated_msg = ""
for letter in message:
if letter == " ":
translated_msg += " "
else:
index = encoded_alpha.find(letter)
if index == -1:
return False
dec_char = alphabet[index]
translated_msg += dec_char
print(translated_msg)
message = input("Enter the string you want encoded: ").lower()
worked = False
while worked == False:
worked = decode(message)
if worked == False:
message = input("Enter the string you want encoded: ").lower()
# CHALLENGE 6 Part 1
def decode(string):
alphabet = "abcdefghijklmnopqrstuvwxyz"
encoded_alpha = "zabcdefghijklmnopqrstuvwxy"
numbers = "0123456789"
encoded_nums = "9012345678"
translated_msg = ""
for letter in message:
if letter == " ":
translated_msg += " "
else:
index = encoded_alpha.find(letter)
if index == -1:
index = encoded_nums.find(letter)
if index == -1:
return False
dec_char = numbers[index]
else:
dec_char = alphabet[index]
translated_msg += dec_char
print(translated_msg)
message = input("Enter the string you want encoded: ").lower()
worked = False
while worked == False:
worked = decode(message)
if worked == False:
message = input("Enter the string you want encoded: ").lower()
# CHALLENGE 6 Part 2
def decode(string):
alphabet = "abcdefghijklmnopqrstuvwxyz"
encoded_alpha = "zabcdefghijklmnopqrstuvwxy"
numbers = "0123456789"
encoded_nums = "9012345678"
specials = ".,!‘?;: “&#@$%^*()/\[]{}|-_+=~"
encoded_specials = "~.,!‘?;: “&#@$%^*()/\[]{}|-_+="
translated_msg = ""
for letter in message:
index = encoded_specials.find(letter)
if index == -1:
index = encoded_alpha.find(letter)
if index == -1:
index = encoded_nums.find(letter)
if index == -1:
return False
enc_char = numbers[index]
else:
enc_char = alphabet[index]
else:
enc_char = specials[index]
translated_msg += enc_char
print(translated_msg)
message = input("Enter the string you want encoded: ").lower()
worked = False
while worked == False:
worked = decode(message)
if worked == False:
message = input("Enter the string you want encoded: ").lower()