why b and c are different here? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
25th Jun 2020, 10:31 PM
Bhanu Pratap Singh Bais
Bhanu Pratap Singh Bais - avatar
2 Answers
+ 5
The list for the default argument is only created once when the function is defined. Whenever you don't pass an argument, the name will refer to the default object. So it's the same one list every time, and it changes when you change it.
25th Jun 2020, 10:53 PM
HonFu
HonFu - avatar
+ 1
HonFu How many little secretes hidden behind python :-)
26th Jun 2020, 4:02 AM
Bhanu Pratap Singh Bais
Bhanu Pratap Singh Bais - avatar