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

[SOLVED] Help needed with the hunt begins

i don’t really know what to write on this level. here’s my code:

def averageSize(burls):
    sum = sumSize(burls)
    return sum / burls.length

def sumSize(burls):
    pass

while True:
    burls = hero.findEnemies()
    averege = averageSize(burls)
    hero.say(averege)

You are just about there…kinda :wink:

In the sumSize function, you need to iterate through the burls array, totalling their health.

Is this function

Find and return the sum of the health values of the elements in the burls array.

@dedreous and @AnSeDra, i don’t get what you mean.

Do you remember the level with the function that finds out the sum of the healths of all the enemies? ( like in the level Gas Attack) Well, do the same thing just for burls instead of enemies.
Do you understand now?

what should the hero say though?

That part you have just fine…hero.say(average) is perfect

here’s my code:

def averageSize(burls):
    sum = sumSize(burls)
    return sum / burls.length

def sumSize(burls):
    totalHealth = 0
    for burl in burls:
        totalHealth += burl.health
    pass

while True:
    burls = hero.findEnemies()
    averege = averageSize(burls)
    hero.say(averege)

You already have it in the base code.

How return the variabile totalHealth out of the sumSize function and you will complete the level.

He’s handling that with this code.

so what am i supposed to do?

Instead of that put this:

burl.size

Before this

Put this:
return totalHealth
Instead of this

Put this:

len(burls)

Does it work now? :face_with_raised_eyebrow:

no. here’s my new code:

def averageSize(burls):
    sum = sumSize(burls)
    return sum / burls.length

def sumSize(burls):
    totalHealth = 0
    for burl in burls:
        totalHealth += hero.size
    return totalHealth
    pass

while True:
    burls = hero.findEnemies()
    averege = averageSize(burls)
    
    hero.say(averege)

Recheck post 14 because I edited it.
Does it work now?

i saw, but instead of what?

Instead of burls.length

Keep in mind that you totaling the burl sizes, not the hero size.

1 Like

So do you need any more assistance at this level?