Recursion is when a function calls itself. Loops are usually preferable to recursion, but recursion is excellent for traversing tree-like structures.
https://pym.dev/what-is-recursion/
Find more Python screencasts at
https://pym.dev/screencasts/
00:00 Recursive functions call themselves
00:25 Use a base case to stop recursion
01:04 Recursion works thanks to the call stack
02:38 Using for loops instead of recursion
02:59 Recursion's most common use case
03:47 Loops are great, but recursion does have its uses
Тэги:
#python