Skip to content

Latest commit

 

History

History
43 lines (25 loc) · 670 Bytes

Mumbling.md

File metadata and controls

43 lines (25 loc) · 670 Bytes

CodeWars Python Solutions


Mumbling

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.


Given Code

def accum(s):
    # your code here

Solution

def accum(s):
    return "-".join([s[i].upper() + (s[i].lower() * i) for i in range(len(s))])

See on CodeWars.com