+ 1

why does the function memorize the last return result when I call the same function again?

the sample code(python3): def fuc(x,l=[]): l.append(x) print(l) fuc(1) fuc(1) fuc(1) the result will be: [1] [1,1] [1,1,1] instead of : [1] [1] [1] so why can the func memerize? and what can do to get rid of the memory after the last call?

6th Apr 2019, 2:17 PM
Dihambo Dior
Dihambo Dior - avatar
2 odpowiedzi
+ 11
14th Apr 2019, 9:12 AM
Janusz Bujak 🇵🇱 🇺🇦
Janusz Bujak 🇵🇱 🇺🇦 - avatar