Oct-04-2023, 11:06 AM
hi
what is difference between f(b) and f(b[:]) in below? when i run them the outputs are different
1)
what is difference between f(b) and f(b[:]) in below? when i run them the outputs are different
1)
b=[1,2] id(b) def f(a): a[0]=3 print("a: ",a, "id(a): ",id(a)) f(b) print("b , id(b)",b,id(b))2)
b=[1,2] id(b) def f(a): a[0]=3 print("a: ",a, "id(a): ",id(a)) f(b[:]) print("b , id(b)",b,id(b))please explain, thanks