Python Why It Says Undefined Variable When I Call Function Stack

Python Why It Says Undefined Variable When I Call Function Stack