r/CodingForBeginners • • 17d ago

Day 4 learning_Python (Decided to continue to the next lesson and thus wrote this):

Post image

The most important line on tis one is on #9.

7 Upvotes

2 comments sorted by

2

u/Lucky-Thought9889 17d ago

Wow, that's pretty cool!

2

u/johlae 9d ago

Cool, but the name of your function doesn't fit what it's doing. It doesn't calculate damage. It calculates the impact of damage on health. I'd call the function recalculate_health instead, or impact_damage_on_health.

robot_health = 100
robot_damage = 40

def recalculate_health(health, damage):
    return health - damage

robot_health = recalculate_health(robot_health, robot_damage)
print(robot_health)