I believe they have the same meaning. I would change the order of "when no hope was there" to "when there was no hope". As we know, during this period (no comma) when there was no hope , the king ruled the kingdom bravely.
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.