You're missing a colon. `if lyr.datasetName == inputlayer:` Also, the last line MXD.save() should be indented an additional 4 spaces.