# programmers, phase1 : 시저 암호, python3
def solution(s, n):
answer = ''
for i in s :
if i.isupper() :
answer += chr(ord(i)+n) if ord(i)+n < 91 else chr(ord(i)-26+n)
elif i.islower() :
answer += chr(ord(i)+n) if ord(i)+n < 123 else chr(ord(i)-26+n)
elif i == ' ' :
answer += i
return answer
https://programmers.co.kr/learn/courses/30/lessons/12926
github