码迷,mamicode.com
首页 > 其他好文 > 详细

递归问路

时间:2020-06-04 01:44:08      阅读:63      评论:0      收藏:0      [点我收藏+]

标签:print   please   def   ase   list   ret   art   imp   lis   

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))

递归问路

标签:print   please   def   ase   list   ret   art   imp   lis   

原文地址:https://www.cnblogs.com/chb420/p/13040854.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!