Fixing boolean syntax error for python