Question: what is undefined error in python?
Answer: You get an undefined name error, but the reason is subtle. Python reads and compiles this code when it's typed interactively or imported from a module. ... But later, when the function is actually run, the assignment hasn't yet happened when the print executes, so Python says you're using an undefined name.