Help explain recursion in python and how it works ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Help explain recursion in python and how it works ?

And applies too

14th Jun 2020, 6:55 PM
Dev Ben
Dev Ben - avatar
4 Answers
14th Jun 2020, 7:40 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 4
benjaminCode https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2465/ and see comments after this lesson - you find many examples there
14th Jun 2020, 7:04 PM
Petr
+ 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
14th Jun 2020, 7:33 PM
Slick
Slick - avatar
0
Thats the best
14th Jun 2020, 7:40 PM
Slick
Slick - avatar