Today we looked at the scope of variables and functions, what can be used where and how.
For Day 12 of my #100DaysOfCode #Python Challenge I made a guessing game. I have to say I think this was not a difficult one! #vCommunity
— Wouter Kursten (@Magneet_nl) January 15, 2021
Notes
scope variable or function defined inside a function isn't available outside of the function (local scope) global scope = function defined outside of a function on top level. to use global var: global_var = 0 def function(): global global_var global_var += 1 this doesn't give a good overview, better use return global_var = 0 def function(): return global_var + 1 global_var = function() naming convention: global constant (not changing variable) define name in captitals NAME="Wouter Kursten"