Seems like the global variable num_flights is not defined, but somehow expected and used during test code.
num_flights
This is the error: global name 'num_flights' is not defined
global name 'num_flights' is not defined