At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga.
Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus.
Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
Carter was the president before Reagan
The answer is Carter, but the form of the question is misleading. It's certainly true Carter made many attempts over the 15 months or so that the hostages were held in the American Embassy in Tehran, including a rescue mission that failed rather ignominiously. It's also true that he eventually succeeded, by paying a monster amount of money, a few billion dollars. It was Iranian money in the first place, money that had been on deposit in the United States, but it had been frozen after the Islamic Revolution until the many claims against the Iranian government by Americans could be settled in court. Carter essentially unfroze the money and sent it back to the Iranians, voiding any and all claims of Americans against Iran, in exchange for the release of the hostages.
Reagan was not given credit for the release because it happened to occur the day before he was sworn in. The reason is that it was widely believed that the only reason the Iranians agreed to Carter's deal at all is because they feared what Reagan might do once he took office. Bear in mind the hostages were seized by the storming of the American Embassy, an act which has always been regarded as an act of war. It was broadly believed, both here and perhaps in Iran, that Reagan would not hesitate to use force to resolve the crisis. Furthermore, it was believed not unlikely that he would do so immediately, without even attempting further negotiation.