+ 1
Help explain recursion in python and how it works ?
And applies too
4 Respostas
+ 6
Don't hate me :)
https://www.sololearn.com/Discuss/307407/?ref=app
+ 4
benjaminCode
https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2465/
and see comments after this lesson - you find many examples there
+ 1
Adding up numbers in a nested array.
num_ls = [[2, 3], 5, 2]
def add_ns_ls(nest_ls):
nums = []
for item in nums_ls:
if isinstance(item, list):
add_ns_ls(item)
else:
nums.append(item)
return sum(nums)
print(add_ns_ls(nums_ls))
Output:
12
0
Thats the best