Kodewick
Start learning →
Basic←→0 / 100

The Ding Dong game

#096BasicMixedLoops5 min

In the Ding Dong game you count from 1 to n. Multiples of 4 say "Ding", multiples of 6 say "Dong", both say "DingDong", and anything else says the number (as a string). Write ding_dong(n) to return the list of what gets said.

Examples
ding_dong(6)→['1', '2', '3', 'Ding', '5', 'Dong']
ding_dong(1)→['1']
main.py
def ding_dong(n):
    said = []
    for i in range(1, n + 1):
        # your code here: check both first, then 4, then 6
        said.append(str(i))
    return said
Ctrl + Enter runs too
Result

Run tries the examples. When they look right, Submit.