Sometimes you put your best effort into something, working long and hard, rallying all the help you possibly can, and generally pulling out all the stops. You stake your reputation and your future on the attempt. But what do you do when that attempt fails?

That's the question Bernie Sanders had to answer earlier today when he stood on a dais in New Hampshire less than two weeks before the Democratic National Convention and officially admitted what we've all known for many weeks: Hillary Clinton is the Democratic nominee for president. 

It wasn't easy. In this long-fought campaign, both candidates have leveled insults at each other and they have genuine philosophical differences, as well as differences on how to run and especially finance a campaign. Campaign staffers told The New York Times that Sanders gave his endorsement grudgingly. But he did give it--because that was clearly the right thing for him to do. Here are some lessons we can all learn from him:

1. Accept reality.

Many observers believe Sanders should have conceded after the California primary in early June, if not sooner. But in this wacky election year, it's worth remembering he had other options open. He could have taken the fight all the way to the convention and challenged Clinton there, which would have put him in the spotlight a little longer. He could even have returned to his party affiliation as Independent and run a third-party campaign in November. None of this would have been good for the nation or likely served his long-term goals but they were he could have made and that many of his supporters were calling for him to make.

He was wise not to. In every failed attempt, there comes a point where the smart move is to acknowledge that you've failed so that you can move on. 

2. Celebrate what you've accomplished.

Very few failures or successes are pure black and white. Even in politics, where holding elected office comes down to how many votes you did or didn't get, there are many shades of gray. You might win, but that victory might commit you to alliances you would not have chosen. You might lose, but still extend your influence beyond what it was before, as Sanders has done. 

So it's smart to look at your failure and celebrate what you have achieved. In his speech, Sanders thanked his supporters who "showed the world that we could run a successful national campaign based on small individual contributions--2 1/2 million of them."

Some observers took exception to his describing his losing campaign as "successful," and yet it was, compared to everyone's expectations. No one, least of all Sanders, thought he had a serious shot at being president back when primary season began.

3. Make the best use you can of what you've done.

Chances are, the effort you put into your failed attempt has yielded some results. In Sanders' case, he lost the nomination, but gained 13 million primary or caucus votes and a legion of deeply enthusiastic followers. Sanders knew he could use that achievement to get some of what he wanted and he has. After lengthy negotiations with the Clinton camp, the two worked out "by far, the most progressive platform in the history of the Democratic Party," he told supporters. 

Whether those positions will last until the election--let alone become policy if Clinton wins--is open to question. Perhaps more substantively, Sanders is likely also getting a prime time speech at the convention and chairmanship of a Senate committee whose goal is to raise the federal minimum wage.

4. Focus on the big picture.

At 74, it seems unlikely that Sanders will ever again run for president. But he still has plenty of larger goals, especially bringing the worsening problem of economic inequality more to the fore. If he had fought on to the convention or beyond, he would have stayed longer on the national stage but likely lost his chance to exert long-term influence on the Democratic Party and on national politics.

The deal he made today may allow him to wield that influence for many years to come.