def get_thing(item, obj):
for i in range(item):
obj.append(i)
return obj
def main():
thing = []
get_thing(5, thing)
print(thing)
main()
I would expect the following code to return
[]
and not
[0,1,2,3,4]
It seems to be working the same way as if I was doing this instead.
thing = get_thing(5, thing)
What is the background process that is going on that results in this kind of return? I noticed this a couple of times in the code at work and was a little perplexed by it and not quite sure how this works.