Programmers 시저 암호

Solution

def solution(s, n):
    answer = list(s)
    for i in range(len(s)):
        if s[i].isupper():
            answer[i] = chr((ord(s[i]) + n - ord('A')) % 26 + ord('A'))
        elif s[i].islower():
            answer[i] = chr((ord(s[i]) + n - ord('a')) % 26 + ord('a'))
    return ''.join(answer)