"""Apply ROT13 encoding.""" import sys # sys.stdout.write() text = raw_input("Input text? ") for idx in range(len(text)): # iterate over string char = text[idx] code = ord(char) if (code >= ord('a')) and (code <= ord('z')): # lower code += 13 if code > ord('z'): # wraparound code -= 26 elif (code >= ord('A')) and (code <= ord('Z')): # upper code += 13 if code > ord('Z'): # wraparound code -= 26 char = chr(code) sys.stdout.write(char) print