Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

[SOLVED] Triage [Python]

#Triage the wounded soldiers
doctor = hero.findByType("paladin")[0]
mage = hero.findByType("pixie")[0]
helper = hero.findByType("peasant")[0]
soldiers = hero.findByType("soldier")

# Initialize patient arrays.
doctorPatients = []
magePatients = []
helperPatients = []

# Iterate all the soldiers:
for soldier in soldiers:
    # If soldier is slowed:
    if soldier.maxSpeed < 6:
        # Add them to the 'mage's array of patients.
        magePatients.append(soldier)
    # Else if soldier.health is less than half of maxHealth:
    elif soldier.health < soldier.maxHealth / 2:
        # Add them to the 'doctor's array of patients.
        doctorPatients.append(soldier)
    # Else:
    else:
        # Add soldier to the 'helper's array of patients.
        helperPatients.append(soldier)

# Now assign the patient lists to the appropriate person.
mage["patients"] = magePatients
doctor["patients"] = doctorPatients
helper["patients"] = helperPatients

Please help I don’t know what to do

Hi @Destroyer5023 and welcome to the forum! :partying_face:

What do you mean? Does it give you any errors?

Your code is like my working one, so try resummiting and it should work fine. Let me know if you encounter any more problems, ok?

oh thanks i beat the level

1 Like

No problem! Glad I could help! :smiley:

1 Like

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.