• + 0 comments
    import math
    import os
    import random
    import re
    import sys
    
    #
    # Complete the 'caesarCipher' function below.
    #
    # The function is expected to return a STRING.
    # The function accepts following parameters:
    #  1. STRING s
    #  2. INTEGER k
    #
    
    def caesarCipher(s, k):
        # Write your code here
        tmp_list = list('abcdefghijklmnopqrstuvwxyz')
        tmp_list1 = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
        s = list(s)
        for i in range(len(s)):
            if s[i] in tmp_list:
                s[i] = tmp_list[(tmp_list.index(s[i])+k)%26]
            elif s[i] in tmp_list1:
                s[i] = tmp_list1[(tmp_list1.index(s[i])+k)%26]
        return ''.join(s)
    
    if __name__ == '__main__':
        fptr = open(os.environ['OUTPUT_PATH'], 'w')
    
        n = int(input().strip())
    
        s = input()
    
        k = int(input().strip())
    
        result = caesarCipher(s, k)
    
        fptr.write(result + '\n')
    
        fptr.close()