If we write a simple program in python as mentioned below, the variables get swapped
num1=5
num2=10
temp = num1
num1 = num2
num2 = temp
print(num1) //10
print(num2) //5
But if we perform the same thing inside a function, the values do not get swapped
def swap(x, y):
temp = x
x = y
y = temp
Driver code
x = 2
y = 3
swap(x, y)
print(x) //2
print(y) //3
I want to know the concept that in first case it is getting swapped but in second case why it is not getting swapped ?