President Barack Obama says he could have been reelected for a third term and that the nation still largely embraces his political vision despite last month’s election of Donald Trump to succeed him.

The US leader’s remarks were made in an interview posted on the podcast “The Axe Files,” produced by CNN and the University of Chicago.

Obama, who winds up his second and final term in office in just over three weeks, said he believes the American public still supports his progressive vision, despite having voted for Trump — his political opposite.

“I am confident in this vision because I’m confident that if I had run again and articulated it, I think I could’ve mobilized a majority of the American people to rally behind it,” Obama tells his interviewer, former senior adviser David Axelrod, in the most recent of several exit interviews he has been conducting.

He was philosophical and a little rueful about Democrats’ loss of the presidential election, when Hillary Clinton was defeated by Trump in a shock outcome almost no one predicted.

“Losing’s never fun,” he tells Axelrod, a political strategist who helped craft Obama’s winning 2008 presidential campaign and then followed him to the White House.

“I’m proud that I have tried to conduct myself in office to do what I think is right rather than what is popular, I always tell people don’t underestimate the public humiliation of losing in politics,” Obama said.

“It’s unlike what most people experience as adults, this sense of rejection.”

But he was also proud of the way the progress made in the two terms of his presidency, thanks to the “spirit of America,” especially evident in the younger generation.

“That spirit of America has still been there in all sorts of ways. It manifests itself in communities all across the country,” Obama said.

“We see it in this younger generation that is smarter, more tolerant, more innovative, more creative, more entrepreneurial, would not even think about, you know, discriminating somebody against for example because of their sexual orientation,” the president said.

“All those things that I describe, you’re seeing in our society, particularly among 20-year-olds, 30-year-olds.’

Despite the election of Trump — a Republican who appears set to put in place policies that will take the country sharply to the right — during his presidency “the culture actually did shift,” Obama told Axelrod.

“The majority does buy into the notion of a one America that is tolerant and diverse and open and full of energy and dynamism,” the US president said.