0

These are the two examples, could someone help me by explaining?

Example 1

v1=list(range(5))
v1temp=v1
v2=1

def ext(x,y):
    return x.append(y)

ext(v1,v2)
print(v1temp)

Example 2

a=1
b=2
atemp=a
a=b
print(atemp)
  • 1
    `list` is a mutable object while `int` is not. There is no method similar to `.append()` for `int`s. – Selcuk Jan 21 '21 at 01:36
  • This question is a more direct duplicate, asking about Python: https://stackoverflow.com/questions/55206114/how-reference-works-in-python-integer-vs-list-in-list-both-value-are-same-why – Jonathon Reinhart Jan 21 '21 at 01:38

0 Answers0