def solution(s, n):
lower_list = "abcdefghijklmnopqrstuvwxyz"
upper_list = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
result = []
for i in s:
if i is " ":
result.append(" ")
elif i.islower() is True:
new = lower_list.find(i) + n
result.append(lower_list[new % 26])
else:
new = upper_list.find(i) + n
result.append(upper_list[new % 26])
return "".join(result)
'Language > Python' 카테고리의 다른 글
[Python / 프로그래머스 level 1] 문자열 내 p와 y의 개수 (0) | 2021.06.30 |
---|---|
[Python / 프로그래머스 level 1] 수박수박수박수박수박수? (0) | 2021.06.30 |
[Python / 프로그래머스 level 1] 약수의 합 (0) | 2021.06.27 |
[Python / 프로그래머스 level 1] 소수 찾기 (0) | 2021.06.25 |
[Python / 프로그래머스 level 1] 문자열 내 마음대로 정렬하기 (0) | 2021.06.24 |