Your code is changing the angle of the sprite in small steps between 0 and rotation+180 and then afterwards (presumably) drawing the sprite. You weren't very specific about what didn't work with your attempt, but my guess is that you aren't actually seeing the sprite move in small steps, but just seeing the final result. This is because you aren't drawing/displaying between steps. You are probably only drawing/displaying after the for loop when it has already completed the full rotation.
An example of what you probably want to do is:
1. Enter your game loop
2. Get the current angle of the sprite
3. Calculate the final angle you want the sprite to have
3. rotate the sprite a small amount towards the final angle (no for loop)
4. Draw the sprite
5. end your game loop
Each loop of your game loop will rotate your sprite a little bit and draw it