0
def fun1(a):
  a=[7, 8]

def fun2(a):
  a[0]=7
  a[1]=8


q=[1,2]

fun1(q)
print(q)

fun2(q)
print(q)

The first one prints out: [1, 2] which means that q has not been changed using fun1. The second one prints out: [1, 2] which means that q is changed when I use fun2.

Why is this happening? What is the underlying difference between the two functions?

0 Answers0