Codewars 7 kyu Kata - Mumbling

DESCRIPTION:
This time no story, no theory. The examples below show you how to write function accum:

Examples:

accum("abcd") -> "A-Bb-Ccc-Dddd"
accum("RqaEzty") -> "R-Qq-Aaa-Eeee-Zzzzz-Tttttt-Yyyyyyy"
accum("cwAt") -> "C-Ww-Aaa-Tttt"

The parameter of accum is a string which includes only letters from a..z and A..Z.

def accum( s ):
    ans = ""
    for i in range( len( s ) ):
        ans += ( s[i] * ( i + 1 ) ).title() + "-"
        
    return ans[ : -1 ]
H2
H3
H4
3 columns
2 columns
1 column
Join the conversation now
Logo
Center