λ¬Έμμ΄ λμλ¬Έμ λ³ν - λ¬Έμ νμ΄
λ¬Έμμ΄ λμλ¬Έμλ₯Ό λ³ννλ 3κ°μ§ νμ΄ λ°©λ²μ νμΈν΄ 보μΈμ.
λ°©λ² 1
def solution(s): result = "" for i in range(len(s)): # λ¬Έμμ΄ κΈΈμ΄λ§νΌ λ°λ³΅ if i % 2 == 0: # μ§μ λ²μ§Έ λ¬Έμλ λλ¬Έμλ‘ result += s[i].lower() # μλ¬Έμλ‘ λ³ν else: # νμ λ²μ§Έ λ¬Έμλ μλ¬Έμλ‘ result += s[i].upper() # λλ¬Έμλ‘ λ³ν return result
λ¬Έμ μ΄μ μ¬μ©νλ©΄ μ
λ ₯λ λ¬Έμμ΄ s
μμ μ§μ λ²μ§Έ λ¬Έμλ μλ¬Έμλ‘,
νμ λ²μ§Έ λ¬Έμλ λλ¬Έμλ‘ λ³νν κ²°κ³Όλ₯Ό λ°νν μ μμ΅λλ€.
μ¬μ© μμ
μ
μΆλ ₯ μμ
input_string = "CoDeFrIeNds" result = solution(input_string) print(result) # μΆλ ₯: "cOdEfRiEnDs"
Guidelines
AI Tutor
Publish
Design
Upload
Notes
Favorites
Help