President Obama condemned the attack on Baton Rouge police officers that resulted in the death of three officers and the wounding of three others, calling on the American people to "temper our words and open our hearts."

"Regardless of motive the death of these three brave officers underscores the danger that police across the country confront every single day," he said Sunday afternoon at the White House. "And we as a nation have to be loud and clear that nothing justifies violence against law enforcement. Attacks on police are an attack on all of us and the rule of law that makes society possible."

Obama said tragedies like Baton Rouge have "happened far too often," referring also to the recent shooting of Dallas police officers earlier this month.

"I've spent a lot of time with law enforcement this last week. I'm surrounded by the best of the best every single day and I know whenever this happens, wherever it happens, you feel it," he said. "What I want you to know today is the respect and gratitude of the American people for everything you do for us."

He especially urged caution over "inflammatory" words as the Republican and Democratic conventions are about to begin, noting that convention season is a time when "our rhetoric tends to be more overheated than usual."

"My fellow Americans, only we can prove through words and through deeds that we will not be divided and we're going to have to keep on doing it again and again and again," he said.

He offered the full support of the federal government to the Baton Rouge police department and mayor and to Louisiana Gov. John Bel Edwards.

"[M]ake no mistake," he promised, "justice will be done."

Obama noted that he called Bel Edwards and Baton Rouge Mayor Kip Holden to get an update on the investigation into the shooting, and he offered his condolences to the families of the slain officers.

Presumptive Democratic nominee Hillary Clinton also condemned the attack Sunday, saying in a statement that there is "no justification for violence."

Presumptive Republican nominee Donald Trump went to social media Sunday morning to express his condolences and later responded to Obama's statement Sunday afternoon.

© 2016 CBS Interactive Inc. All Rights Reserved.