in Python why do I get “name ‘a’ is not defined” even though I have defined it as global? [duplicate]
This question already has answers here: UnboundLocalError trying to use a variable (supposed to be global) that is (re)assigned (even after first use) (14 answers) Closed 14 days ago. Here is example code: async def main(): a = 10 async def test(): global a a +=2 print(a) await test() asyncio.run(main()) and the resulting error: a […]