Nov-29-2017, 07:24 AM
1) There's nothing wrong with that. As long as the function you're calling exists, then you can call it. And since you're calling it immediately after defining it, that's fine.
2) Defining them in the global scope makes them globals, but it doesn't make them constants.
3) You defined it in the global scope, but not within the function's scope. There's a couple ways to fix this. The easiest would be to simply move the definition so it's within the function, since you never use it outside the function, anyway. The second, would be to re-define it within the function, thus hiding whatever value is in the global scope. The third is to use the
2) Defining them in the global scope makes them globals, but it doesn't make them constants.
3) You defined it in the global scope, but not within the function's scope. There's a couple ways to fix this. The easiest would be to simply move the definition so it's within the function, since you never use it outside the function, anyway. The second, would be to re-define it within the function, thus hiding whatever value is in the global scope. The third is to use the
global
keyword, to make it clear that you're using a variable from a higher scope level.