알고리즘
프로그래머스)시저 암호-python
1일1공부실천하자
2023. 2. 13. 00:24
https://school.programmers.co.kr/learn/courses/30/lessons/12926#
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
def solution(s, n):
answer = ''
for i in s:
isLower = False
if i == ' ':
answer += ' '
else:
if i.isupper():
i=i.lower()
isLower = True
num = int(ord(i))
num = num + n
if num > 122:
num = 96 + (num - 122)
alpha = chr(num)
if isLower:
alpha=alpha.upper()
answer += alpha
return answer