← 返回题库
中级

实现卡组发布前验证规则

未完成
中级参考 代码结构已给出,请填写 ____ 处
def solve():
    def validate_publish(____):
        errs=[]
        if deck.get(____)<____: errs.append(____)
        if not deck.get(____): errs.append(____)
        if len(str(deck.get(____)).strip())<____: errs.append(____)
        qa=[c for c in cards if c.get(____)=='____']
        if len(____)<len(____)*____: errs.append(____)
        return len(____)==____, errs
    tests=[
        (____),
        (____),
    ]
    print(____)
    for d,c in tests:
        ok,errs=validate_publish(____)
        print(____)

示例

输入
solve()
期望输出
Deck publish validation:
  name='Python基础' cards=20: VALID []
  name='' cards=3: INVALID ['too_few_cards', 'missing_name', 'description_too_short', 'too_few_qa']
Python 代码 🔒 登录后使用
🔒

登录后即可练习

注册免费账号,在浏览器中直接运行 Python 代码