FAQs on the exercise Don’t Use Mutable Default Arguments
There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.
If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.
Join the Discussion. Help a fellow learner on their journey.
Ask or answer a question about this exercise by clicking reply () below!
Agree with a comment or answer? Like () to up-vote the contribution!
Hi, I was still a little confused on the concept so I searched further online and came upon this information I believe may be useful for future learners as they come to this point. I hope it helps, happy coding!
Very useful! This is the relevant text in your link, which really should have been mentioned in the Codecademy lesson:
“Python’s default arguments are evaluated once when the function is defined, not each time the function is called (like it is in say, Ruby). This means that if you use a mutable default argument and mutate it, you will and have mutated that object for all future calls to the function as well.”
Based on the hint, does that mean doesn’t matter what variable you call the list (order2, order1, or you can call it whatever), it will update for all variables? Did I understand it correctly?