python3 unboundlocalerror local variable referenced before assignment