2011 Ford Fiesta AC warm while parked, cold when driving

My AC started blowing hot air when the car was stopped, but blew cold air when it was moving. The problem turned out to be the electric fan for the radiator and ac condenser.