python3递归(寻路问题)

import time

people_list = ['马云', '马化腾', '李彦宏', 'th','赵薇']


def ask_way(people_list):
    print('*' * 60)
    if len(people_list) == 0:
        return '不知道路'
    people = people_list.pop(0)
    if people == 'th':
        return "%s说:重邮在重庆市南岸区崇文路2号,坐346公交车就能到。"%people
    print('记者问:%s您好,您知道重邮在哪吗?' % people)
    print('%s回答:我不知道,我帮您问问%s吧' % (people, people_list))
    time.sleep(1)
    res = ask_way(people_list)
    print('%s问的结果是:%s'%(people,res))
    return res


res = ask_way(people_list)
print(res)

猜你喜欢

转载自blog.csdn.net/maergaiyun/article/details/82387717
今日推荐