Ad

Code a function, ceasar, that takes two arguments: string and pos.

Your task is to shift all letters by pos.
if pos is 1,
E.g. a -> b, z->a
pos can be negative
if pos is -2,
E.g. a -> y

Keep all other characters as it is.

def ceasar(string,pos):
    ans = ""
    if pos<0:
        pos=26+pos%26
    for ch in string:
        if ch.isupper():
            ans += chr((ord(ch) + pos-65) % 26 + 65) 
        elif ch.islower():
            ans += chr((ord(ch) + pos-97) % 26 + 97)
        else: ans+=ch
    return ans