# \[SOLVED\] Triage \[Python\]

**URL:** <https://discourse.codecombat.com/t/solved-triage-python/22215>\
**Category:** Level Help\
**Created:** [June 14, 2020, 9:28am UTC](https://discourse.codecombat.com/t/solved-triage-python/22215 "2020-06-14T09:28:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Destroyer5023](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/destroyer5023/32/14913_2.png) [@Destroyer5023](https://discourse.codecombat.com/u/Destroyer5023)\
**Post date:** [June 14, 2020, 9:28am UTC](https://discourse.codecombat.com/t/solved-triage-python/22215/1 "2020-06-14T09:28:06Z")

</div>

```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

---

<div class="post-metadata">

**Author:** ![AnSeDra](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ansedra/32/13123_2.png) [@AnSeDra](https://discourse.codecombat.com/u/AnSeDra)\
**Post date:** [June 14, 2020, 9:30am UTC](https://discourse.codecombat.com/t/solved-triage-python/22215/2 "2020-06-14T09:30:39Z")

</div>

Hi @Destroyer5023 and welcome to the forum! 🥳

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

---

<div class="post-metadata">

**Author:** ![AnSeDra](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ansedra/32/13123_2.png) [@AnSeDra](https://discourse.codecombat.com/u/AnSeDra)\
**Post date:** [June 14, 2020, 9:35am UTC](https://discourse.codecombat.com/t/solved-triage-python/22215/3 "2020-06-14T09:35:26Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Destroyer5023](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/destroyer5023/32/14913_2.png) [@Destroyer5023](https://discourse.codecombat.com/u/Destroyer5023)\
**Post date:** [June 14, 2020, 11:13am UTC](https://discourse.codecombat.com/t/solved-triage-python/22215/4 "2020-06-14T11:13:41Z")

</div>

oh thanks i beat the level

---

<div class="post-metadata">

**Author:** ![AnSeDra](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ansedra/32/13123_2.png) [@AnSeDra](https://discourse.codecombat.com/u/AnSeDra)\
**Post date:** [June 14, 2020, 11:18am UTC](https://discourse.codecombat.com/t/solved-triage-python/22215/5 "2020-06-14T11:18:08Z")

</div>

No problem! Glad I could help! 😃

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/a/a9445509d1a758c41b5ddcddc8c8e20a5dedb67f.png) [@system](https://discourse.codecombat.com/u/system)\
**Post date:** [August 27, 2020, 9:28am UTC](https://discourse.codecombat.com/t/solved-triage-python/22215/6 "2020-08-27T09:28:53Z")

</div>

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