Kodewick
开始学 →
基础←→0 / 100

待办完成了几项

#097基础综合字符串约 4 分钟

待办清单里,做完的事前面写着 [x],没做完的写着 [ ]。写 todo_progress(tasks),返回像 "2/5" 这样的字符串:做完几项 / 一共几项。空清单返回 "0/0"。

示例
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:
        # 在这里写:以 "[x]" 开头,done 就加 1
        pass
    return f"{done}/{len(tasks)}"
Ctrl + Enter 也能运行
结果

写好了先点「运行」试试示例,没问题再点「提交」。