DEV Community

loading...

Discussion on: Daily Challenge #210 - Separate Capitalization

Collapse
ksyula profile image
Ksenia

One more Python solution:

def capitalize(s: str) -> list:
    cap_s_even, cap_s_odd = "", ""
    for i in range(0, len(s)):
        if i % 2 == 0:
            cap_s_even+=s[i].upper()
            cap_s_odd+=s[i]
        else:
            cap_s_even+=s[i]
            cap_s_odd+=s[i].upper()
    return [cap_s_even, cap_s_odd]