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
In the sumSize function, you need to iterate through the burls array, totalling their health.
Is this function
ActualllOLLIEpop:
def sumSize(burls):
pass
Find and return the sum of the health values of the elements in the burls array.
1 Like
@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
1 Like
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.
1 Like
He’s handling that with this code.
1 Like
so what am i supposed to do?
ActualllOLLIEpop:
burl.health
Instead of that put this:
burl.size
Before this
ActualllOLLIEpop:
pass
Put this:
return totalHealth
Instead of this
ActualllOLLIEpop:
burls.length
Put this:
len(burls)
1 Like
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?
Keep in mind that you totaling the burl sizes, not the hero size.
2 Likes
So do you need any more assistance at this level?
1 Like