新手python学徒,求教。以下为代码
prompt = "\nTell me something, and I will repeat it back to you:"
prompt += "\nEnter 'quit' to end the program. "
active = True
while active:
message = input(prompt)
if message != 'quit':
print(message)
else:
active = False
以下为结果
Tell me something, and I will repeat it back to you:
Enter 'quit' to end the program. quit
quit
Tell me something, and I will repeat it back to you:
Enter 'quit' to end the program. quit
进程已结束,退出代码0
问题一:
为什么第一遍输入quit后循环并没有停止?
问题二:
不符合条件语句if if message != 'quit': 的情况执行了print(message)的原因是什么?
问题三:
为什么第二遍输入quit后循环停止了?
解释器为Pycharm