+ 1
Function inside funtion
Can someone help me understand the following please? I end up with something called 'RecursionError'. 1.def say_hello(): 2. say_hello() 3. 4.def count_to_10(): 5. for a in range(1, 11): 6. print(a) 7. 8.say_hello() 9.count_to_10() 10.say_hello()
4 Réponses
+ 4
A recursive function must have a base case, that is a condition that makes the function stops calling it itself. Yours does not. That is why you have an error. Look at all the recursive functions you have encountered and you will see that there is always a statement that makes the function stops calling itself.
+ 3
The say_hello() function is calling itself indefinitely.. So it just goes on and on and that causes an error
+ 2
Thank you all for your answers.
0
sumply you create an infinity loop.