Encrypted String

Input Format

The first line contains the integer, , the length of the unencrypted string.
The second line contains the unencrypted string, .
The third line contains , the number of letters to rotate the alphabet by.

Output Format

For each test case, print the encoded string.

Sample Input

11
middle-Outz
2

Sample Output

okffng-Qwvb

Explanation

Original alphabet:      abcdefghijklmnopqrstuvwxyz
Alphabet rotated +2: cdefghijklmnopqrstuvwxyzab

m -> o
i -> k
d -> f
d -> f
l -> n
e -> g
- -
O -> Q
u -> w
t -> v
z -> b
Solution:
#!/bin/python3

import math
import os
import random
import re
import sys

# Complete the caesarCipher function below.
def bla(d,k,j):
    s1=""
    d-=k
    x=122-d
    e1=k-x
    d1=97+(e1-1)
    j=chr(d1)
    if(j.isalpha()==True):
        s1=s1+j
        return s1
    else:
        bla(d,k,j)
def falana(d,k,j):
    s1=""
    d-=k
    x=90-d
    e1=k-x
    d1=65+(e1-1)
    j=chr(d1)
    if(j.isalpha()==True and j.isupper()==True):
        s1=s1+j
        return s1
    else:
        falana(d,k,j)
def caesarCipher(s, k):
    s1=""
    if(k!=0):
        if(26%k==26):
            k=k%26
    elif(k==0):
        return s
    for c in s:
        if(c.isalpha()==True and c.islower()==True):
            d=ord(c)
            d+=k
            j=chr(d)
            if(j.isalpha()==True):
                s1=s1+j
            else:
                s1+=bla(d,k,j)
                
        elif(c.isalpha()==True and c.isupper()==True):
            d=ord(c)
            d+=k
            j=chr(d)
            if(j.isalpha()==True and j.isupper()==True):
                s1=s1+j
            else:
                s1+=falana(d,k,j)
        else:
            s1=s1+c
    return s1

if __name__ == '__main__':
    fptr = open(os.environ['OUTPUT_PATH'], 'w')

    n = int(input())

    s = input()

    k = int(input())

    result = caesarCipher(s, k)

    fptr.write(result + '\n')

    fptr.close()