Obama did lose an election. In 2000, he lost a Democratic primary race for Illinois’s 1st congressional district in the United States House of Representatives to four-term incumbent Bobby Rush by a margin of two to one.
Romney's loss to Ted Kennedy was probably a good thing as Romney himself noted in the 2012 GOP debates.