RosettaCodeData/Task/Rot-13/Python/rot-13-4.py

16 lines
551 B
Python
Raw Permalink Normal View History

2015-02-20 00:35:01 -05:00
#!/usr/bin/env python
2018-06-22 20:57:24 +00:00
from __future__ import print_function
2015-02-20 00:35:01 -05:00
import string
2018-06-22 20:57:24 +00:00
lets = string.ascii_lowercase
key = {x:y for (x,y) in zip(lets[13:]+lets[:14], lets)}
key.update({x.upper():key[x].upper() for x in key.keys()})
encode = lambda x: ''.join((key.get(c,c) for c in x))
if __name__ == '__main__':
2015-02-20 00:35:01 -05:00
"""Peform line-by-line rot-13 encoding on any files listed on our
command line or act as a standard UNIX filter (if no arguments
specified).
"""
import fileinput
for line in fileinput.input():
2018-06-22 20:57:24 +00:00
print(encode(line), end="")