Hello.
While doing some exercise to prepare for the exam I found myself multiple times with the same "bug" ( allow me the term). Whenever I define a recursive function with some default parameters if I do not specify in the function call those default arguments everything goes wild ( wrong output for some of the tests) .
For example I define the recursive function foo like:
def foo(path,dic ={}, level =1) :
And I call it with :
foo(path)
It doesn't work, while if I call in the following way :
foo(path, {}, 1)
It works fine.
I am really curious to understand why this happens.
Thank for any answer in advance!!!!
PS when I talk about the call I mean not in the recursive function itself but when I call it from the "main"
While doing some exercise to prepare for the exam I found myself multiple times with the same "bug" ( allow me the term). Whenever I define a recursive function with some default parameters if I do not specify in the function call those default arguments everything goes wild ( wrong output for some of the tests) .
For example I define the recursive function foo like:
def foo(path,dic ={}, level =1) :
And I call it with :
foo(path)
It doesn't work, while if I call in the following way :
foo(path, {}, 1)
It works fine.
I am really curious to understand why this happens.
Thank for any answer in advance!!!!
PS when I talk about the call I mean not in the recursive function itself but when I call it from the "main"