标签:递归 def 逆序 append tmp return app visio pre
接上回:将一个数逆序列放入列表中,例如1234 => [4,3,2,1]。要求用递归实现。lst = []
def int_to_list(tmp:int):
division_number = tmp / 10
demo_number = tmp % 10
tmp3 = division_number - demo_number / 10
if tmp3:
int_to_list(int(tmp3))
lst.append(demo_number)
return lst
print(int_to_list(12345)[::-1])
标签:递归 def 逆序 append tmp return app visio pre
原文地址:https://blog.51cto.com/6298641/2482899