Question: python 3 question: how can you initialize a list to be used recursively(aka to be preserved) without declaring it as a mutable default argument when

python 3 question:

how can you initialize a list to be used recursively(aka to be preserved) without declaring it as a mutable default argument when using recursion:

eg. instead of this:

def my_move(yeah,blah=[])

I want this to work recursively:

def my_move(yeah,blah=None)

if blah is None:

blah=[]

except i want it to keep the list after the first round and not keep replacing it. Thanks

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!