4 odpowiedzi
+ 1
Global variables are the one that are defined and declared outside a function and we need to use them inside a function.
https://www.google.com/amp/s/www.geeksforgeeks.org/global-local-variables-JUMP_LINK__&&__python__&&__JUMP_LINK/amp/
0
Emanuel Maliaño thanks! But how is it possible that variable s could be 2 thing in the same time? In one of the examples in the site they showed that the variable s is 2 things.. how?
0
The variable s does not have two states at the same time, but has two different scopes, the first assignment is within the function, so that variable is part of the function and cannot be accessed from outside. The second one is in scope. global so you can access it from any part of your program but if you access this variable within a function and you want to change its value you must use the global keyword.
0
Emanuel Maliaño got it! Thanks!