My old iPhone might not be reliable enough to use as a phone, but it still works as an iPod shuffle.
The iPhone was my everyday mobile phone for a decade, but toward the end, it was getting harder to use as a phone. For example, the battery life got shorter, and the home button did not trigger reliably. After I retired it from use as a phone, it just sat on a shelf. When I needed a music player, it was the obvious solution.
The iPhone automatically has the Music app installed, so all I really had to do was create a new playlist in iTunes, load it onto the phone, then open this playlist in the Music app and set it to Shuffle All. To minimize disruptions, I changed the settings for other apps on the phone. For example, I turned off notifications and removed email accounts. If you were given a phone that someone else had used, it would surely be easier to start with an erase and reset before setting it up to play music.
This arrangement is not quite as convenient as an actual iPod shuffle. The play/pause button is on the screen, so I have to turn the screen on every time I want to play or pause the music. And of course, a phone is larger and heavier than an iPod. But it works for what I am doing. It beats having to pay for something new.