Rot13 in Python

Published on 23 December 2018 (Updated: 15 October 2020)

Welcome to the Rot13 in Python page! Here, you'll find the source code for this program as well as a description of how the program works.

Current Solution

import sys
from string import ascii_uppercase, ascii_lowercase

def rot_13(string):
    return ''.join([encrypt_char(c) for c in string])

def encrypt_char(c):
    if c in ascii_uppercase:
        ltrs = ascii_uppercase
    elif c in ascii_lowercase:
        ltrs = ascii_lowercase
        return c
    new_index = (ltrs.index(c) + 13) % 26
    return ltrs[new_index]

def exit_with_error():
    print('Usage: please provide a string to encrypt')

def main(args):
        string = args[0]
        if len(string) <= 0:
    except (IndexError, ValueError):

if __name__ == "__main__":

Rot13 in Python was written by:

If you see anything you'd like to change or update, please consider contributing.

How to Implement the Solution

No 'How to Implement the Solution' section available. Please consider contributing.

How to Run the Solution

No 'How to Run the Solution' section available. Please consider contributing.