Create a combat function that takes the player's current health and the amount of damage recieved, and returns the player's new health.
Health can't be less than 0.

Difficulty: EASY
Tags: Fundamentals

Starter code:
def combat(health, damage):
	

Solutions:
def combat(health, damage):
	return max(0, health - damage)


def combat(health, damage):
	return health - damage if health > damage else 0


def combat(h, d):
	return max(0, h - d)


combat = lambda h, d: (h > d) * (h - d)


def combat(health, damage):
	return (damage < health) * (health - damage)


combat = lambda health, damage: health - damage if health - damage > 0 else 0


def combat(health, damage):
	return health - min(health, damage)


def combat(health, damage):
	owca = health - damage
	if owca < 0:
		return 0
	return owca


combat = lambda h, d: max(h - d, 0)


def combat(health, damage):
	return {health - damage > 0: health - damage}.get(True, 0)


def combat(health, damage):
	return damage < health and health - damage


def combat(health, damage):
	result = health - damage
	if result < 0:
		result = 0
	return result


def combat(health, damage):
	a = health
	b = damage
	c = a - b
	if c >= 0:
		return c
	else:
		return 0


def combat(h, d):
	if h < d:
		return 0
	else:
		return h - d


combat = lambda h, d: h - d if h > d else 0


def combat(health, damage):
	while health - damage >= 0:
		return health - damage
	else:
		return 0


def combat(h, dmg):
	return h - dmg if h > dmg else 0


def combat(health, damage):
	rest = health - damage
	if rest < 0:
		return 0
	return rest


def combat(hp, dp):
	return hp - dp if hp - dp > 0 else 0


import unittest

def combat(health, damage):
	if health <= damage:
		return 0
	return health - damage

class TestCombat(unittest.TestCase):

	def test_should_return_0_when_given_damage_is_greater_than_health(self):
		self.assertEqual(combat(health=20, damage=30), 0)

	def test_combat_with_given_health_is_greater_than_damage(self):
		self.assertEqual(combat(health=100, damage=5), 95)


def combat(health, damage):
	list1 = health - damage
	if list1 > 0:
		return list1
	if list1 <= 0:
		return 0


def combat(health, damage):
	result = health - damage
	result_korr = max(result, 0)
	return result_korr


def combat(health, damage):
	if damage > health:
		return 0
	elif health > damage:
		return health - damage


def combat(health, damage):
	return bool(health > damage) * (health - damage)


def combat(health, damage):
	r = health - damage
	if r < 0:
		return 0
	return r


def combat(health, damage):
	h = health
	d = damage
	x = h - d
	if x < 0:
		return 0
	else:
		return x


def combat(health, damage):
	k = health - damage
	if k < 0:
		return 0
	return k


def combat(health, damage):
	after = health - damage
	if after < 0:
		return 0
	return after


def combat(x, y):
	return x - y if x > y else 0


def combat(health, damage):
	f = 0
	if health > damage:
		f = health - damage
	return f


def combat(health, damage):
	ret = health - damage
	if 0 > ret:
		ret = 0
	return ret


def combat(health, damage):
	result = health - damage
	if result < int(0):
		return result * 0
	else:
		return result


def combat(health, damage):
	b = 0
	b = health - damage
	if b < 0:
		b = 0
	return b


def combat(health, damage):
	healthnew = health - damage
	if healthnew < 0:
		healthnew = 0
	return healthnew


def combat(health, damage):
	try:
		if health < damage:
			return 0
		else:
			return health - damage
	except:
		if health < 0:
			return 'health needs to be greater than zero'


def combat(health, damage):
	return [health - damage, 0][health - damage < 1]


def combat(health, damage):
	case = health - damage
	if case < 0:
		case = 0
	return case


def combat(health, damage):
	if health - damage < 0:
		return 0
	elif health - damage > 0:
		return health - damage
	else:
		return int(health)


def combat(a, b):
	if a - b <= 0:
		return 0
	else:
		return a - b


def combat(heal, dam):
	return max(0, heal - dam)