prompt = "Please tell me something,and I will repeat it to you:\n"
prompt += "If you enter'quit',you will end the program.\n"
while True:
if input(prompt) != 'quit':
print(input(prompt))
else:
break
Please tell me something,and I will repeat it to you:
If you enter'quit',you will end the program.
a
Please tell me something,and I will repeat it to you:
If you enter'quit',you will end the program.
aa
aa
Please tell me something,and I will repeat it to you:
If you enter'quit',you will end the program.
s
Please tell me something,and I will repeat it to you:
If you enter'quit',you will end the program.
ss
ss
Please tell me something,and I will repeat it to you:
If you enter'quit',you will end the program.
print(input(prompt))
这是在玩啥呢
你前面不把input的内容先保存起来,后面print
而是用于判断是否是quit,后面用户必须再次输入一个内容,然后输出这个内容
prompt = "Please tell me something,and I will repeat it to you:\n"
prompt += "If you enter'quit',you will end the program.\n"
def a():
while True:
message = input(prompt)
if message == 'quit':
break
print(message)
a()
这样就可以了,你看看有没有达到你的需求