나의 답안

def solution(s):
    answer = list(s)
    count = 0
    for i in range(len(s)):
        if s[i] == " ":
            count = 0
            continue
        else:
            if count % 2 == 0 or count == 0:
                answer[i] = answer[i].upper()
            else:
                answer[i] = answer[i].lower()
        count += 1

    return "".join(answer)

 

살펴볼만한 답안

def toWeirdCase(s):
    return " ".join(map(lambda x: "".join([a.lower() if i % 2 else a.upper() for i, a in enumerate(x)]), s.split(" ")))

+ Recent posts