is a list call by referance or call by value python code example
Example: Is Python call by reference or call by value
If the object is mutable, the object will change.
eg:
def my_func(my_list):
my_list.append(5)
print("List printed inside the function: ",my_list)
numberlist = [1,2,3]
my_func(numberlist)
If the object is immutable (like a string!),
then a new object is formed, only to live within the function scope.
eg:
def change_fruits(fruit):
fruit='apple'
myfruit = 'banana'
change_fruits(myfruit)