Python Help - Encoding and Decoding Using ORD and CHR (ASCII)

Saturday, May 3, 2014

So I'm teaching myself to code, and I'm doing the challenge where you use ord and chr to encode and decode messages with ASCII. I stumbled onto this code (below) on another question, and was wondering if there was an easy way to convert it to decode, rather than encode? :-)



phrase = raw_input("Enter text to Cipher: ")
shift = int(raw_input("Please enter shift: "))
result = ""

for character in phrase:
x = ord(character)
result += chr(x + shift)

print result






http://ift.tt/1fDn0A1