python unboundlocalerror local variable x referenced before assignment