# your code goes hereb = 6 def f_a(): print(a) def f_b(): print(b) def g_a(): if False: a = 5 print(a) def g_b(): if False: b = 5 print(b) for f in [f_a, f_b, g_a, g_b]: print(f.__name__) try: f() except Exception as e: print(type(e), e) print()
Standard input is empty
f_a <class 'NameError'> name 'a' is not defined f_b 6 g_a <class 'UnboundLocalError'> local variable 'a' referenced before assignment g_b <class 'UnboundLocalError'> local variable 'b' referenced before assignment
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!