0

One more answer from a challenge that I’m not understanding

def extend(num, list = []): list.append(num) return list x = extend(1) y = extend(2) print(x, y) ///////////// output: [1, 2] [1, 2] I get why “y” is [1, 2] but x confuses me a lot

20th Apr 2020, 7:02 PM
António
António - avatar
1 Antwort
+ 1
~ swim ~ so what you are saying is that since the list is stored in both x and y variables, then once y has changed the list, x is going to store that most recent change of the list?
20th Apr 2020, 7:29 PM
António
António - avatar