alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] def intro(): output=[] global output phrase=input("Enter a phrase to work with (/ used for space): ") phrase=phrase.lower() global phrase s1=input("Enter setting number 1, x < 10: ") s2=input("Enter setting number 2, x < 10: ") s3=input("Enter setting number 3, x < 10: ") s4=input("Enter setting number 4, x < 10: ") s1=int(s1)*2 s2=int(s3)+3*2 s3=int(s2)+4 s4=int(s4)+2 global s1 global s2 global s3 global s4 intro() def encode(): for c in phrase: if c == "/": output.append('/') elif c == " ": output.append('-') else: pos_c=alpha.index(str(c)) pos_c = pos_c+int(s1) pos_c = pos_c+int(s2) pos_c = pos_c+int(s3) pos_c = pos_c-int(s4) output.append(alpha[pos_c].upper()) output.append('') print (''.join(output)) input("Press Enter To Continue...") def decode(): for c in phrase: if c == "/": output.append('/') elif c == " ": output.append('') else: pos_c=alpha.index(str(c)) pos_c = pos_c-int(s1) pos_c = pos_c-int(s2) pos_c = pos_c-int(s3) pos_c = pos_c+int(s4) output.append(alpha[pos_c].upper()) output.append(' ') print(''.join(output)) input("Press Enter To Continue...") def main_menu(): main=input("Would you like to [encode] or [decode]?: ") if main == "encode": encode() elif main == "decode": decode() else: print("Sorry, that input was not an option!") main_menu() main_menu()
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question