The bombing was not revenge per se, but the Japanese never surrendered even when outnumbered 20 to 1. Even worse, the last Japanese standing would probably blow himself up with a grenade to take out a few Americans with him.
In this light, the Japanese basically “forced” the US to literally go with the Nuclear option: using such outrageous force on an already weakened enemy, just to get them to surrender.