Guidelines

카이사λ₯΄ μ•”ν˜Έ - 문제 풀이

카이사λ₯΄ μ•”ν˜Έλ₯Ό 파이썬으둜 κ΅¬ν˜„ν•œ 2가지 방법을 확인해 λ³΄μ„Έμš”.


방법 1
def solution(text, shift): alphabet = 'abcdefghijklmnopqrstuvwxyz' result = '' for char in text: if char.isalpha(): index = alphabet.index(char.lower()) shifted_index = (index + shift) % 26 shifted_char = alphabet[shifted_index] result += shifted_char.upper() if char.isupper() else shifted_char else: result += char return result

μ‚¬μš© μ˜ˆμ‹œ

μž…μΆœλ ₯ μ˜ˆμ‹œ
result = solution("abc", 3) print(result) # 좜λ ₯: "def"

Guidelines

AI Tutor

Publish

Design

Upload

Notes

Favorites

Help