Answers for "python referenced before assignment in function"

6

python local variable referenced before assignment

variable = "Hello"
def function():
  global variable
  print(variable)
function()
Posted by: Guest on February-20-2020
1

python referenced before assignment in function

# When Python parses the body of a function definition and encounters an assignment such as

 feed = 5 
#Python interprets feed as a local variable by default. If you do not wish for it to be a local variable, you must put

global feed
feed = 5
Posted by: Guest on December-15-2020

Code answers related to "python referenced before assignment in function"

Python Answers by Framework

Browse Popular Code Answers by Language