Here is my rotating code:
pos = pygame.mouse.get_pos()
x_dist = pos[0] - self.rect.centerx
y_dist = -(pos[1] - self.rect.centery)
self.angle = math.degrees(math.atan2(y_dist, x_dist))
self.image = pygame.transform.rotate(self.original_image, self.angle)
Here is my image:
The problem is, when I rotate it, I have to subtract the angle by 90 to get the right result.
I have searched all over stack overflow but nothing works.

print()to check if your calculations are correct. Maybe it needscenterx - pos[0]instead ofpos[0] - centerx(and the same withy)