标题:照书本上抄的代码,为啥不运行?
取消只看楼主
greenpop
Rank: 1
等 级:新手上路
帖 子:73
专家分:3
注 册:2011-12-22
结帖率:88.24%
 问题点数:0 回复次数:1 
照书本上抄的代码,为啥不运行?
responses={}

polling_active=True

while polling_active:
    name=input("\nWhat is your name?")
    response=input("which mountain would you like to climp someday?")

    responses[name]=response

    repeat=input("Would you like to let another person respond?(yes/no")
    if repeat=='no':
        polling_active=False

print("\n---Poll Result---")
for name,response in response.items():
    print(name+" would like to climb"+response+".")


错误信息:

What is your name?zwg

Traceback (most recent call last):
  File "F:/pythonst/mountain_poll.py", line 6, in <module>
    name=input("\nWhat is your name?")
  File "<string>", line 1, in <module>
NameError: name 'zwg' is not defined
>>>
搜索更多相关主题的帖子: like 代码 input name response 
2019-11-06 10:35
greenpop
Rank: 1
等 级:新手上路
帖 子:73
专家分:3
注 册:2011-12-22
得分:0 
在python 2 上运行老出错。在python3上运行正常。谢谢楼上。
2019-11-06 17:08



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-497637-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.113003 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved