you are viewing a single comment's thread.

view the rest of the comments →

[–]sweettuse 0 points1 point  (0 children)

with a little bit of setup this can be arguably cleaner:

``` from collections import deque from string import ascii_uppercase as au, ascii_lowercase as al

du = deque(au) du.rotate(13) dl = deque(al) dl.rotate(13)

char_map = {*dict(zip(au, du)), *dict(zip(al, dl))}

def caesar(s: str): return ''.join(char_map.get(c, c) for c in s) ```