[Programmers] - 시저 암호 (Level 1)
연습문제
LEVEL : 1
문제링크
s = "a B z"
n = 4
def solution(s, n):
low = 'abcdefghijklmnopqrstuvwxyz'*2
up = low.upper()
answer =[]
for i in range(len(s)):
if s[i] == ' ':
answer.append(' ')
elif s[i] in low:
answer.append(low[low.index(s[i])+n])
elif s[i] in up:
answer.append(up[up.index(s[i])+n])
return ''.join(answer)
solution(s,n)
'e F d'
Comments