Reputation: 1383
I am trying to set up a AWS Lambda function and as always, I am keeping my constants in global variables. But for some reason, I am getting the error shown below. I do this all the time and never have issues. I've typed this myself and retyped it a bunch of times so no weird unicode characters. I think I'm going crazy.
Upvotes: 1
Views: 1281
Reputation: 35188
This is because you set b = False
in the same function. By setting it in the function it redefines the variable as a local variable rather than a global variable.
To use it like this you need to define b as a global variable such as
def lambda_handler(event, context):
global b
print(b[0])
b = False
Upvotes: 3