rotate player upsdide down,how to make a sprite rotate upside down than back rightside up

I am making a 2d game that whenever you touch the ceiling the gravity flips. But i cant figure out how to make the player rotate and then un rotate. i already have the flip gravity just not rotation

transform.localEulerAngles = new Vector3 (0,0,180)

Then set back to zero to turn the right way up again