To learn more about Python, I was reading the book How to Think Like a Computer Scientist: Learning with Python by Allen Downey, Jeffrey Elkner, and Chris Meyers -which you can get from here– and in chapter 4.9 I read about recursion.
Basically, recursion is when you create a function that calls itself. This solves some kind of problems that would otherwise require the use of a loop. In the book there was an example of this in chapter 5.5, in which a factorial function was defined using recursion. As perhaps you may remember (or not), I had already done a program that calculated the factorial of a number, and I showed it on my post called Factorial Calculator!
So, after I learned about this topic I decided to redo the program, but using recursion to see how it worked.
I did it like this:
Notice I also used .upper() to get the result to the question of whether the user wished to do it again or not. I talked about this method on my last post.
Anyway, the program ran exactly like the first one I made:
Here is a useful tutorial to understand this better: