def fun(a, p=0):
if(p == len(a)):
return 0
z=1 if not a[p] else 0
return z + fun(a,p+1)
a = [1,0,1,1,0,1,0]
print(fun(a))
A 4
B Error
C 7
D 3
正确答案是3
谁告诉我,这三儿从 哪来的?
...全文
1742打赏收藏
谁能理清这里头的逻辑关系
what is the output of this code? def fun(a, p=0): if(p == len(a)): return 0 z=1 if not a[p] else 0 return z + fun(a,p+1) a = [1,0,1,1,0,1,0] print(fun(a)) A 4 B Error C 7 D 3 正确答案是3 谁告诉我,这三儿从 哪来的?