Click here to Skip to main content
15,884,425 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Python
if skill1 < 0:
        skill1 = 0

    elif skill2 < 0:
        skill2 = 0

    elif strength1 <= 0:
        print ("%s is dead") % (character1)

    elif strength2 <= 0:
        print ("%s is dead") % (character2)
Posted
Updated 6-Dec-14 3:50am
v2

1 solution

Hi,

I think that's because you're using if-else statement.

If skill1 is equal or greater than 0 then other ifs are not executed...

Try this way:

Python
if skill1 < 0:
    skill1 = 0
 
if skill2 < 0:
    skill2 = 0
 
if strength1 <= 0:
    print ("%s is dead") % (character1)
 
if strength2 <= 0:
    print ("%s is dead") % (character2)


Here you have link to if-else in python language:
http://www.tutorialspoint.com/python/python_if_else.htm[^]

Hope it help you.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900