Each phone model unlocks in a different way. Best to use a search engine, with this as a search string:
unlock [your exact Sprint Phone Model] Sprint with code howto
DO NOT insert the new SIM until you've unlocked the phone successfully according to the instructions you find, as you run the risk of bricking (making the phone inoperable).
Follow the instructions exactly. Usually (varies highly), you turn the phone completely off, then hold the power button with the Volume UP button; things vary after that. Read through any forum you see that matches the search to see if subsequent entries offer corrections or notes to consider before attempting this. Go to a franchise (not a Sprint Store) if you need help, but they may charge you for the help. Good luck!