person=['B','C','D','E'] know=False def askway(address): #问路 if len(person)>0 and know is False: name=person.pop() def ask(): print('%s,你知道%s怎么走吗?'%(name,address)) answer=input() if answer=='Y': know=True answer_address=input('请输入具体地址') print('%s知道%s怎么走,具体为%s'%(name,address,answer_address)) else: print('%s不知道,请询问下一个人'%name) askway(address) ask() else: print('没有人知道') x='nanjing' askway(x)