Kodewick
Start learning →
Basic←→0 / 100

To-do progress

#097BasicMixedStrings4 min

In the to-do list, finished jobs start with [x] and unfinished ones with [ ]. Write todo_progress(tasks) to return a string like "2/5": how many are done / how many in all. An empty list gives "0/0".

Examples
todo_progress(["[x] feed the cat", "[ ] tidy desk", "[x] water plants"])→'2/3'
todo_progress([])→'0/0'
main.py
def todo_progress(tasks):
    done = 0
    for task in tasks:
        # your code here: starts with "[x]"? add 1 to done
        pass
    return f"{done}/{len(tasks)}"
Ctrl + Enter runs too
Result

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