Python program that stops looping and gets stuck randomly
Question: I've been trying hard to learn Python for some time now and I'm stuck trying
to make this simple program work.

As you can see, what I'm trying to do is get 4 values to 'battle' until one is
left. It goes fine and dandy until anywhere from loop #11 to #22, and then it
just stops. I'm a complete beginner, and dont know what I'm doing wrong.

    
    
    import random
    import math
    import os
    
    print '     ----------------------------------'
    print '       UNIVERSAL ALL-STARS DEATHMATCH'
    print '     ----------------------------------'
    print ''
    print 'CHOOSE FOUR CHARACTERS TO FIGHT IN AN FFA DEATHMATCH!'
    print ''
    
    #User input for character names.
    characterInputted = False
    while characterInputted == False:
        character1 = raw_input('Input Character 1 Name:')
        character2 = raw_input('Input Character 2 Name:')
        character3 = raw_input('Input Character 3 Name:')
        character4 = raw_input('Input Character 4 Name:')
        if character1 == character2:
            print 'Cannot have any characters with identical names!'
            characterInputted = False
        elif character1 == character3:
            print 'Cannot have any characters with identical names!'
            characterInputted = False
        elif character1 == character4:
            print 'Cannot have any characters with identical names!'
            characterInputted = False
        elif character2 == character3:
            print 'Cannot have any characters with identical names!'
            characterInputted = False
        elif character2 == character4:
            print 'Cannot have any characters with identical names!'
            characterInputted = False
        elif character3 == character4:
            print 'Cannot have any characters with identical names!'
            characterInputted = False
        else:
            characterInputted = True
    
    def combat_roll():
        combatValid = False
        while combatValid == False:
            rollAtk = random.randint(1, 4)
            rollDef = random.randint(1, 4)
            if rollAtk == rollDef:
                combatValid = False
    #Roll for char1
            elif rollAtk == character1_Number:
                if character1_Dead == True:
                    combatValid = False
                elif rollDef == character2_Number:
                    if character2_Dead == True:
                        combatValid = False
                    else:
                        rollAttacker = character1
                        rollDefender = character2
                        combatValid = True
                        return rollAttacker, rollDefender
                elif rollDef == character3_Number:
                    if character3_Dead == True:
                        combatValid = False
                    else:
                        rollAttacker = character1
                        rollDefender = character3
                        combatValid = True
                        return rollAttacker, rollDefender
                elif rollDef == character4_Number:
                    if character4_Dead == True:
                        combatValid = False
                    else:
                        rollAttacker = character1
                        rollDefender = character4
                        combatValid = True
                        return rollAttacker, rollDefender
    #Roll for char2
            elif rollAtk == character2_Number:
                if character2_Dead == True:
                    combatValid = False
                elif rollDef == character1_Number:
                    if character1_Dead == True:
                        combatValid = False
                    else:
                        rollAttacker = character2
                        rollDefender = character1
                        combatValid = True
                        return rollAttacker, rollDefender
                elif rollDef == character3_Number:
                    if character3_Dead == True:
                        combatValid = False
                    else:
                        rollAttacker = character2
                        rollDefender = character3
                        combatValid = True
                        return rollAttacker, rollDefender
                elif rollDef == character4_Number:
                    if character4_Dead == True:
                        combatValid = False
                    else:
                        rollAttacker = character2
                        rollDefender = character4
                        combatValid = True
                        return rollAttacker, rollDefender
    #Roll for char3
            elif rollAtk == character3_Number:
                if character1_Dead == True:
                    combatValid = False
                elif rollDef == character1_Number:
                    if character2_Dead == True:
                        combatValid = False
                    else:
                        rollAttacker = character3
                        rollDefender = character1
                        combatValid = True
                        return rollAttacker, rollDefender
                elif rollDef == character2_Number:
                    if character2_Dead == True:
                        combatValid = False
                    else:
                        rollAttacker = character3
                        rollDefender = character2
                        combatValid = True
                        return rollAttacker, rollDefender
                elif rollDef == character4_Number:
                    if character4_Dead == True:
                        combatValid = False
                    else:
                        rollAttacker = character3
                        rollDefender = character4
                        combatValid = True
                        return rollAttacker, rollDefender
    #Roll for char4
            elif rollAtk == character4_Number:
                if character1_Dead == True:
                    combatValid = False
                elif rollDef == character1_Number:
                    if character1_Dead == True:
                        combatValid = False
                    else:
                        rollAttacker = character4
                        rollDefender = character1
                        combatValid = True
                        return rollAttacker, rollDefender
                elif rollDef == character2_Number:
                    if character2_Dead == True:
                        combatValid = False
                    else:
                        rollAttacker = character4
                        rollDefender = character2
                        combatValid = True
                        return rollAttacker, rollDefender
                elif rollDef == character3_Number:
                    if character3_Dead == True:
                        combatValid = False
                    else:
                        rollAttacker = character4
                        rollDefender = character3
                        combatValid = True
                        return rollAttacker, rollDefender
            else:
                combatValid = False
    
    #Roundtick set to zero
    roundNumber = 0
    
    #Characters randomly generated stats.
    character1_Attackbonus = random.randint(0, 2)
    character1_Number = 1
    character1_Dead = False
    character1_LifeCount = 1
    
    character2_Attackbonus = random.randint(0, 2)
    character2_Number = 2
    character2_Dead = False
    character2_LifeCount = 1
    
    character3_Attackbonus = random.randint(0, 2)
    character3_Number = 3
    character3_Dead = False
    character3_LifeCount = 1
    
    character4_Attackbonus = random.randint(0, 2)
    character4_Number = 4
    character4_Dead = False
    character4_LifeCount = 1
    
    gameover = False
    while gameover == False:
        os.system('cls')
        lifeCount_Total = [character1_LifeCount +
                           character2_LifeCount + character3_LifeCount +
                           character4_LifeCount]
        roundNumber = roundNumber + 1
        print 'Round #%d!' % roundNumber
        raw_input('Press ENTER to continue.')
        attackChance = random.randint(0, 10)
        if lifeCount_Total > 2 == True:
            gameover = True
        elif attackChance < 3:
            print "No one attacked this round!"
        elif attackChance > 3:
            Attacker, Defender = combat_roll()
            print Attacker + ' attacked ' + Defender + '.'
            Attackbase = random.randint(0, 10)
    #Combat calculations!
            combatCalc = False
            while combatCalc == False:
                if Attacker == character1:
                    AttackTotal = Attackbase + character1_Attackbonus
                    if Defender == character2:
                        if AttackTotal > 5:
                            character2_Dead = True
                            character2_LifeCount = 0
                            print '%s killed %s!' % (Attacker, Defender)
                            combatCalc = True
                        else:
                            print '%s failed to kill %s!' % (Attacker, Defender)
                            combatCalc = True
                    elif Defender == character3:
                        if AttackTotal > 5:
                            character3_Dead = True
                            character3_LifeCount = 0
                            print '%s killed %s!' % (Attacker, Defender)
                            combatCalc = True
                        else:
                            print '%s failed to kill %s!' % (Attacker, Defender)
                        combatCalc = True
                    elif Defender == character4:
                        if AttackTotal > 5:
                            character4_Dead = True
                            character4_LifeCount = 0
                            print '%s killed %s!' % (Attacker, Defender)
                            combatCalc = True
                        else:
                            print '%s failed to kill %s!' % (Attacker, Defender)
                            combatCalc = True
    
                elif Attacker == character2:
                    AttackTotal = Attackbase + character2_Attackbonus
                    if Defender == character1:
                        if AttackTotal > 5:
                            character1_Dead = True
                            character1_LifeCount = 0
                            print '%s killed %s!' % (Attacker, Defender)
                            combatCalc = True
                        else:
                            print '%s failed to kill %s!' % (Attacker, Defender)
                            combatCalc = True
                    elif Defender == character3:
                        if AttackTotal > 5:
                            character3_Dead = True
                            character3_LifeCount = 0
                            print '%s killed %s!' % (Attacker, Defender)
                            combatCalc = True
                        else:
                            print '%s failed to kill %s!' % (Attacker, Defender)
                        combatCalc = True
                    elif Defender == character4:
                        if AttackTotal > 5:
                            character4_Dead = True
                            character4_LifeCount = 0
                            print '%s killed %s!' % (Attacker, Defender)
                            combatCalc = True
                        else:
                            print '%s failed to kill %s!' % (Attacker, Defender)
                            combatCalc = True
    
                elif Attacker == character3:
                    AttackTotal = Attackbase + character3_Attackbonus
                    if Defender == character1:
                        if AttackTotal > 5:
                            character1_Dead = True
                            character1_LifeCount = 0
                            print '%s killed %s!' % (Attacker, Defender)
                            combatCalc = True
                        else:
                            print '%s failed to kill %s!' % (Attacker, Defender)
                            combatCalc = True
                    elif Defender == character2:
                        if AttackTotal > 5:
                            character2_Dead = True
                            character2_LifeCount = 0
                            print '%s killed %s!' % (Attacker, Defender)
                            combatCalc = True
                        else:
                            print '%s failed to kill %s!' % (Attacker, Defender)
                        combatCalc = True
                    elif Defender == character4:
                        if AttackTotal > 5:
                            character4_Dead = True
                            character4_LifeCount = 0
                            print '%s killed %s!' % (Attacker, Defender)
                            combatCalc = True
                        else:
                            print '%s failed to kill %s!' % (Attacker, Defender)
                            combatCalc = True
    
                elif Attacker == character4:
                    AttackTotal = Attackbase + character4_Attackbonus
                    if Defender == character1:
                        if AttackTotal > 5:
                            character1_Dead = True
                            character1_LifeCount = 0
                            print '%s killed %s!' % (Attacker, Defender)
                            combatCalc = True
                        else:
                            print '%s failed to kill %s!' % (Attacker, Defender)
                            combatCalc = True
                    elif Defender == character2:
                        if AttackTotal > 5:
                            character2_Dead = True
                            character2_LifeCount = 0
                            print '%s killed %s!' % (Attacker, Defender)
                            combatCalc = True
                        else:
                            print '%s failed to kill %s!' % (Attacker, Defender)
                        combatCalc = True
                    elif Defender == character3:
                        if AttackTotal > 5:
                            character3_Dead = True
                            character3_LifeCount = 0
                            print '%s killed %s!' % (Attacker, Defender)
                            combatCalc = True
                        else:
                            print '%s failed to kill %s!' % (Attacker, Defender)
                            combatCalc = True
                else:
                    combatCalc = False        
        else:
            gameover = False
    
    print character1
    print character2
    print character3
    print character4
    


Answer: I tested your code and it seems that it doesn't stop but enter in the function
`combat_roll()` and is stuck in it. If I print `combatValid`, I obtain :

    
    
    `false 
     false
     false
     ...
    

