This week I am thinking about recursion. I have encountered functions such as max, any, all, sum. Recursion consist of a base case and a continuous case. If I reach the end of the base case I stop and recursion keep calling itself if I have the continuous case.
I learned that If I need to keep calling my function to count the sum or count I need to use sum. I return 0 if I hit None and return 1 if I have an element. Then I use the sum function to sum them up. Any function tells if there's a true. It is useful when I want to see if I have a even number in my nested list and all function is useful when I want to see if all the list is even.
No comments:
Post a Comment