> 알고리즘 문제 풀이/프로그래머스
lv1-시저 암호 (python, 파이썬)
bky373
2020. 10. 22. 17:21
""" 나의 풀이 """
def solution(s, n):
uppers = [ s for s in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ']
lowers = [ s for s in 'abcdefghijklmnopqrstuvwxyz']
ans = ''
for x in s:
if x == ' ':
ans += ' '
else:
if x.isupper():
ans += uppers[(uppers.index(x)+n)%26]
else:
ans += lowers[(lowers.index(x)+n)%26]
return ans