Is there a better way to write this

if item.hp <= item.max_hp / 2: item.hp += 10; if item.hp > item.max_hp: item.hp = item.max_hp

What do you mean by better? An alternative is this:

if item.hp <= item.max_hp / 2:
    item.hp += 10
else:
    item.hp = min(item.hp, item.max_hp)
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.