Python的递归练习:问路
2021-05-20 22:29
标签:col print def 递归 class int code time lis Python的递归练习:问路 标签:col print def 递归 class int code time lis 原文地址:https://www.cnblogs.com/lihai1020/p/9739636.html 1 import time
2
3 person_list = ["桂香", "黄熙", "李海"]
4
5
6 def getAskWay(person_list):
7 print("-" * 20)
8 if len(person_list) == 0:
9 return "没人知道"
10
11 person = person_list.pop(0)
12 if person == "李海":
13 return "%s:我知道,就在..." % (person)
14
15 print("hi,帅哥 %s,敢问路在何方?" % person)
16 print("%s:我不知道,但念你慧眼识猪,我去帮我你问问 %s ..." % (person, person_list[0]))
17 time.sleep(2)
18 rst = getAskWay(person_list)
19 print("%s问的结果是:%s" % (person, rst))
20 return rst
21
22
23 rst = getAskWay(person_list)
24 print(rst)