1

The code -

def f(i=[]):
  i.append(1)
  return i
print(f())
print(f())

The Output -

[1]
[1, 1]

Why the function f() returns [1,1] as 2nd output instead of [1], because it assigns a new list every time when calling, but the list keeps appending the number... Is there any reason

Thank you

0 Answers0