def CaeserCipher(s, k): L = [] for i in range(0, len(s)): if((ord(s[i]) >= ord("a") and ord(s[i]) <= ord("z"))): # check if it is small alphabets temp = ord(s[i]) - ord("a") # store the difference between the ASCII of our alphabet and ASCII of 'a'. x = (temp + k) % 26 # compute cipher from Wikipedia formula x = x + ord("a") # add back ord("a"), which was subtracted initially L.append(chr(x)) # add this to our list elif((ord(s[i]) >= ord("A") and ord(s[i]) <= ord("Z"))): # repeat above step for capital letters temp = ord(s[i]) - ord("A") x = (temp + k) % 26 x = x + ord("A") L.append(chr(x)) else: L.append(s[i]) # not alphabet, add to list return ''.join(L) # generate our string, preserving the format of original string #main program print "please enter text. Hit return key after entering text:" line = raw_input() s = "" k = -1 # The arbitrarily chosen key for Caeser Cipher while line: s = s + line + "\n" line = raw_input() print CaeserCipher(s, k)