鱼C论坛

 找回密码
 立即注册
查看: 1002|回复: 2

[已解决]报错

[复制链接]
发表于 2021-1-5 09:59:20 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
def print_models(unprinted_designs, completed_models):
    """
    模拟打印每个设计,直到没有未打印的设计为止
    打印每个设计后,都将其移到列表completed_models中
    """
    while unprinted_designs:
        current_design = unprinted_designs.pop()
        # 模拟根据设计制作3D打印模型过程
        print("Printing model: " + current_design)
        completed_models.append(current_design)
               
def show_completed_models(completed_models):
    """显示打印好的所有模型"""
    print("\nThe following models have been printed:")
    for completed_model in completed_models:
        print(completed_model)
               
unprined_designs = ['iphone case', 'robot pendant' , 'dodecahedron']
completed_models = []

print_models(unprinted_designs, completed_models)
show_completed_models(completed_models)

报错:
File "D:/Python34/print_models.py", line 21, in <module>
    print_models(unprinted_designs, completed_models)
NameError: name 'unprinted_designs' is not defined
我已经定义了,为什么报错显示是无错误呢??
请大佬指教
最佳答案
2021-1-5 10:07:42
unprined_designs = [....]    unprinted  你少打了个t
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2021-1-5 10:07:35 | 显示全部楼层
定义列表的时候少个t:unprinted_designs
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

头像被屏蔽
发表于 2021-1-5 10:07:42 | 显示全部楼层    本楼为最佳答案   
提示: 作者被禁止或删除 内容自动屏蔽
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 1 反对 0

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-5-13 04:44

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表