Parameters not working as intended

This was functioning fine, but then something happened and I’m not sure what I did to change it, but modifying the variable in a parameter isn’t working anymore.

Repl link:

something along the lines of

def attack(target)
target -= 3

attack(enemy1hp)

and having enemy1hp remain unchanged

You would have to do something like this

def attack (target):
    return target - 3

enemy1hp = attack(enemy1hp)

one problem with this - the attack function is not just simply that, but also inflicts things like status effects and varies depending on the “equipped weapon” - would return still acquire the same value or would t not work in this scenario?

If you were using objects, you could do something like this

class Enemy:
    def __init__(self):
        self.health = 100
        # self.status = ....
        # .....

def attack(target):
    target.health -= 3

enemy = Enemy()
attack(enemy)

Or even better assuming there is a player as well

class Entity:
    def __init__(self, health, weapon_damage):    
        self.health = health
        self.weapon_damage = weapon_damage
        # self.status = ....
        # .....

    def attack(self, target):
        target.health -= self.weapon_damage

class Player(Entity):
    def __init__(self):
        super().__init__(100, 3)
        # Player only attributes, these subclasses might not be necessary

class Enemy(Entity):
    def __init__(self, health, weapon_damage):
        super().__init__(health, weapon_damage)
        # Enemy only attributes

enemy  = Enemy(50, 1)
player = Player()

player.attack(enemy)

This is not an exact implementation, but more like a guide of how I would possibly approach this :slightly_smiling_face:

Great, thank you so much!