Ho to use if Function?
<p>I have been making a text-based RPG in python 3.5. I had it fine (or so i thought...) until i tried to say that no I did not want to play. And also when I wanted to make the option to run from Mobs, but instead it combines both if functions, and says the amount of damage AND that you 'Ran away.' I tried to switch around some code but that made it even worse! I need help.
</p>

<pre><code>import time
import random
import sys
import time
global gold
global player_HP
global Mob_HP_1
global Mob_HP_2
global Mob_HP_3
global Mob_HP_0
mob_HP_1 = 100
mob_HP_2 = 125
mob_HP_3 = 130
gold = 0
def Demon_attack():
            global Mob_HP_3
            Mob_HP_3 = 130
            global gold
            attack_damage=random.randint(50,200)
            rewards=random.randint(1,5)
            print('You do')
            print(attack_damage)
            print('damage!')
            Mob_HP_3 = Mob_HP_3 - attack_damage
            if Mob_HP_3 &lt; 0:
                print ('You killed the')
                print ('Demon!')
            if Mob_HP_3 &gt; 0:
                print('The Demon has')
                print(Mob_HP_3)
                print('HP left!')
                choice_attack_3 = input('Do you attack?')
                if choice_attack_3 == 'A'or 'a':
                    Demon_attack()
                if choice_attack_3 == 'R' or 'r':
                    print('You run away!')
                    time.sleep (2)
                    battle_start()
            time.sleep (3)
            gold=gold+rewards
            print('You have')
            print(gold)
            print('Gold!')
            battle_start()

def Headless_Horseman_attack():
            global Mob_HP_2
            Mob_HP_2 = 125
            global gold
            attack_damage=random.randint(50,200)
            rewards=random.randint(1,5)
            print('You do')
            print(attack_damage)
            print('damage!')
            Mob_HP_2 = Mob_HP_2 - attack_damage
            if Mob_HP_2 &lt; 0:
                print ('You killed the')
                print ('Headless Horseman')
            if Mob_HP_2 &gt; 0:
                print('The Headless Horseman has')
                print(Mob_HP_2)
                print('HP left!')
                choice_attack_2 = input('Do you attack?')
                if choice_attack_2 == 'A' or 'a':
                    Headless_Horseman_attack()
                if choice_attack_2 == 'R' or 'r':
                    print('You run away!')
                    time.sleep (2)
                    battle_start()
            time.sleep (2)
            gold=gold+rewards
            print ('You have')
            print(gold)
            print('Gold!')
            battle_start()

def Zombie_attack():
            global Mob_HP_1
            Mob_HP_1 = 100
            global gold
            attack_damage=random.randint(50,200)
            rewards=random.randint(0,5)
            print('You do')
            print(attack_damage)
            print('damage!')
            Mob_HP_1 =  Mob_HP_1 - attack_damage
            if Mob_HP_1 &lt; 0:
                print ('You killed the')
                print ('Zombie!')
            if Mob_HP_1 &gt; 0:
                print('The Headless Horseman has')
                print(Mob_HP_1)
                print('HP left!')
                choice_attack_1 = input('Do you attack?')
                if choice_attack_1 == 'A' or 'a':
                    Zombie_attack()
                if choice_attack_1 == 'R' or 'r':
                    print('You run away!')
                    time.sleep (2)
                    battle_start()
            time.sleep (1.5)
            gold=gold+rewards
            print('You have')
            print(gold)
            print('Gold!')
            battle_start()

def battle_start():
    global gold
    if gold &gt; 50:
        print ('You have killed all the monsters!')
        play = input('Do you want to play again? Y/N?')
        if choice == 'Y' or 'y':
            game_start()
        if choice == 'N' or 'a':
            print ('Okay, battle later')
            time.sleep(4)
            sys.exit(0)
    time.sleep (3)
    attack_damage=random.randint(50,200)
    rewards=random.randint(1,3)
    mob=random.randint(1,3)
    if mob==1:
        mob_alive = True
        print('You ran into a Zombie!')
        print('The Zombie has 100 HP!')
        choice_attack_1 = input('Do you attack?')
        if choice_attack_1 == 'A' or 'a':
            Zombie_attack()
        if choice_attack_1 == 'R' or 'r':
            print('You run away!')
            time.sleep (2)
            battle_start()
    if mob==2:
        mob_alive = True
        print('You ran into a Headless Horseman!')
        print('The Headless Horseman has 125 HP!')
        choice_attack_2 = input('Do you attack?')
        if choice_attack_2 == 'A' or 'a':
            Headless_Horseman_attack()
        if choice_attack_2 == 'R' or 'r':
            print('You run away!')
            time.sleep (2)
            battle_start()
    if mob==3:
        mob_alive = True
        print('You ran into a Demon!')
        print('The Demon has 130 HP!')
        choice_attack_3 = input('Do you attack?')
        if choice_attack_3 == 'A' or 'a':
            Demon_attack()
        if choice_attack_3 == 'R' or 'r':
            print('You run away!')
            time.sleep (2)
            battle_start()
def game_start(): 
    global gold
    global Mob_HP_0
    Mob_HP_0 = 25
    print('You have to get 50 Gold to win!')
    attack_damage=random.randint(50,200)
    rewards=random.randint(1,3)
    print('To Attack, type "A". To Run Away, type "R". Lets pratice...')
    print('Pratice Mob has 25 HP!')
    choice_attack = input('Do you attack?')
    if choice_attack == 'A' or 'a':
        print('You do')
        print(attack_damage)
        print('damage!')
        Mob_HP_0 = Mob_HP_0 - attack_damage
    if choice_attack == 'R' or 'r':
        print('You ran away!')
        time.sleep (2)
        game_start()
        time.sleep (1.5)
        gold = gold + rewards
        print('You have ')
        print(gold)
        print('gold!')
    print ('Good job')
    print ('Lets start the battle...')
    battle_start()
print ('Welcome to Battle Deongeons')
myName = input('Whats your name?')
print ('Ok ' + myName + ' you need to kill monsters... Be careful though, its capital Sentsive.')
choice = input("Do you want to play? Y/N")
if choice == "Y" or "y":
    print('Lets start the Battle')
    game_start()
if choice == "N" or "n":
    print ('Okay, battle later')
    time.sleep (4)
    sys.exit(0)
</code></pre>



<pre><code>            if choice_attack_3 == 'A'or choice_attack_3 == 'a':
                Demon_attack()
            elif choice_attack_3 == 'R' or choice_attack_3 == 'r':
                print('You run away!')
                time.sleep (2)
                battle_start()
</code></pre>

<p>You need to add choice_attack_3 == on the other side of your <code>or</code> statement. <code>'a'</code> by itself is technically true so it is entering both if statements. </p>

<p>Edit: same with</p>

<pre><code>if choice == "Y" or choice == "y":
    print('Lets start the Battle')
    game_start()
if choice == "N" or choice == "n":
</code></pre>

python