Syntax error on else

It would help if your indentation showed, see the about posting for how to do that.

That being said, I think you want
opener = “open” if sys.platform == “darwin” else “xdg-open”
without the colons and on one line. This is not an if statement, but an if operator.