Answer
When an electric current flows in a wire, it creates a magnetic field around the wire. This effect can be used to make an electromagnet. A simple electromagnet comprises a length of wire turned into a coil and connected to a battery or power supply.
A coil of insulated wire is wrapped around an iron nail. One end of the coil of wire is connected to a battery. The other is connected to a switch in the circuit
A simple electromagnet
You can make an electromagnet stronger by doing these things:
wrapping the coil around a piece of iron (such as an iron nail)
adding more turns to the coil
increasing the current flowing through the coil
There is a limit to how much current can be passed safely through the wire because the resistance of the wire causes heating.