HELP | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

HELP

Here is my code Health = 50 EHealth = 50 Alive = 1 print("Hi") def Fight(): while 1 == 1: if 50 >= 0: print("You died") Alive = 0 break if EHealth <= 0: print("You killed the enemy") Alive = 1 break Fight print("bye") The code basically ignores the function. What am I doing wrong?

13th Sep 2018, 4:20 PM
Jason Smith
Jason Smith - avatar
1 Answer
+ 1
I'm no Python expert, but I suppose you have to call the method with parentheses, e.g. Fight() (correct me if I'm wrong, though). Also, 50 is always bigger than 0, so the first if-statement is the one that is always executed. Maybe you meant "Health" there?
13th Sep 2018, 4:30 PM
Shadow
Shadow - avatar