tishi=‘\ntell me sth,and i will repeat it back to you.’
tishi+=“\nEnter ‘quit’ to stop the program.”
tishi+=“\nnow you can enter:”
me=‘’#初始值
while me!=‘quit’:
me=input(tishi)
if me!=‘quit’:
print(me)
如果要添加测试(如elif语句)以检查是否有事件发生导致active变为False,flag更有用
tishi=‘\ntell me sth,and i will repeat it back to you.’
tishi+=“\nEnter ‘quit’ or ‘no’ or 'stop’to stop the program.”
tishi+=“\nnow you can enter:”
active=True
while active:
message=input(tishi)
if message==‘quit’:
active=False
elif message==‘no’:
active=False
elif message==‘stop’:
active=False
else:
print(message)