Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # The Finnish death metal band Demilich released an album in 1993 called
- # "Nespithe". The liner notes, as well as the album title and one song title,
- # are written in code: start at the end of the phrase, group the letters in
- # three, and reverse the groups' order.
- def encode(string):
- string = string.replace(" ","")
- newstr = ""
- for i in range(0,len(string),3):
- newstr = string[i:i+3] + newstr
- return newstr.upper()
- def decode(string):
- string = string.replace(" ","")
- newstr = ""
- for i in range(len(string),2,-3):
- newstr += string[i-3:i]
- newstr += string[0:i%3]
- return newstr.upper()
- fkey = None
- while fkey != "q":
- function = input("[E]ncode, [D]ecode, or [Q]uit? ")
- fkey = function[0].lower()
- if fkey == "q":
- continue
- elif fkey == "e":
- string = input("String to encode: ")
- print(encode(string))
- elif fkey == "d":
- string = input("String to decode: ")
- print(decode(string))
- print("Flying out of this world to another land...")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement