def fillList(listToFill,n):
listToFill=range(1,n+1)
a new list is created inside the function scope and disappears when the function ends. useless.
def fillList(listToFill,n):
listToFill=range(1,n+1)
return listToFill()
you return the list and you must use it like this:
newList=fillList(oldList,1000)
- And finally without returning arguments:
def fillList(listToFill,n):
listToFill.extend(range(1,n+1))
and call it like this:
fillList(oldList,1000)
Conclusion:
Inside a function , if you want to modify an argument you can reassign it and return it, or you can call the object's methods and return nothing.
You cannot just reassign it like if you were outside of the function and return nothing, because it's not going to have effect outside the function.