이상한 문자 python

송다은·2024년 10월 15일
def solution(s):
    text = s.split(' ') #공백 구조 유지를 위해 ' ' 로 나누어줌 
    
    new_text = []
    for i in text: # try
        word =''
        for idx,j in enumerate(i): # 0 1 2 t r y
            if idx % 2 == 0:
                word+=j.upper()
            else:
                word+=j.lower()
        new_text.append(word)
        #print(new_text)
    return ' '.join(new_text)

keypoint

  • 리스트에서도 공백을 유지하고 싶다면 split(' ')로 나누어줄 것!!
profile
Anomaly Detection, AI Security, Multimodal

0개의 댓글