|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
作业连接:https://fishc.com.cn/thread-45159-1-1.html
动动手的答案部分有一些看不太懂,我把疑惑的部分代码贴上去,希望各位路过朋友帮忙解惑。
我不理解为什么要建立chosen这个变量
答案为:
while True:
chosen = False
while not chosen:
choice = input(prompt)
if choice not in 'NnEeQq':
print('您输入的指令代码错误,请重新输入:')
else:
chosen = True
if choice == 'q' or choice == 'Q':
break
if choice == 'n' or choice == 'N':
new_user()
if choice == 'e' or choice == 'E':
old_user()
为何不能直接删除chosen变量改为:
while True:
choice = input(prompt)
if choice not in 'NnEeQq':
print('您输入的指令代码错误,请重新输入:')
if choice == 'q' or choice == 'Q':
break
if choice == 'n' or choice == 'N':
new_user()
if choice == 'e' or choice == 'E':
old_user()
第一次发求助帖,不知道是否合规范,先谢谢大家了。
当输入不正确时,还需做后面三个if判断,增加程序的运行时间
|
|