Hi,

Can someone please explain me the reason for below output.

Program:
def fun(n,li = []):
    a = list(range(5))
    li.append(a)
    print(li)

fun(4)
fun(5,[7,8,9])
fun(4,[7,8,9])
fun(5) # reason for output (why am I getting to values in this output.)

Output:
[[0, 1, 2, 3, 4]]
[7, 8, 9, [0, 1, 2, 3, 4]]
[7, 8, 9, [0, 1, 2, 3, 4]]
[[0, 1, 2, 3, 4], [0, 1, 2, 3, 4]]

Thank you,
Gursimran
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to