递归问路
Posted chb420
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了递归问路相关的知识,希望对你有一定的参考价值。
import time
person_list = ["chb", "wmq", "xxy", "lyp", "wzq"]
def ask_way(person_list):
print("-" * 60)
if len(person_list)== 0 :
return"no one can help you"
person=person_list.pop(0)
if person=="wzq":
return" %s :the way is in my heart." % person
print("[%s],where is the way to MJY?" %person)
print("%s: I don‘t know ,please ask the others such as %s"%(person,person_list))
time.sleep(3)
res=ask_way(person_list)
return res
res=ask_way(person_list)
匿名函数
def calc(n):
return n**n
print(calc(10))
calc = lambda n:n**n
print(calc(10))
以上是关于递归问路的主要内容,如果未能解决你的问题,请参考以下文章