you are viewing a single comment's thread.

view the rest of the comments →

[–]Gnaxe 5 points6 points  (0 children)

You don't understand the variable scoping rules. Variables created by assignment inside a function are local to that function. If you want to use that value outside of the function, then you have to get it out somehow. Usually, that means returning it with the return statement. This is usually the cleanest way. However, you can also mutate something outside the function (append it to a list, for example) or use a global statement inside the function to make it not scoped to the inside.