What are the differences between a motor and a generator?

I know they both use electromagnets, but how do they use them differently?

motors do work from electricity

generators convert work to electricity.

In simple forms, a motor or generator is the same unit, it just depends on how they are used. If the driving EMF is greater than the induced emf, mechanial work is done by the "motor", if the driving mechinical linkage is doing more work than the emf is doing, the induced emf willbe greater, and emf is being generating. If the applied emf is equal to the induced emf (commnly called back emf), no mechanical work is being done, and the unit is in equilibrium, typically spinning under no load. A motor/generator is a conversion device between electrical and mechanical, and it can operate either direction, if designed properly (simple motors and generators at the same thing).