How do you make the classic 100 coins equal an extra life logic?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By sumguy05

This bests describe what I’m trying to accomplish. I tried this logic with 4 instead for time’s sake and it worked poorly I got an extra life a coin instead

func set_coin(new_value):
coins = new_value
if coins % 4: health += 1

What is the best way to get this working?

:bust_in_silhouette: Reply From: kidscancode

That’s because you’re not checking the condition properly. If you want to add a life when coins is divisible by 4, then coins % 4 is going to be 0. So that’s what you should test for:

if coins % 4 == 0:
    health += 1

Thank you I feel slow. I love your videos by the way even though I haven’t been a kid in years lol.

sumguy05 | 2019-01-07 01:20