# Help: the hunt begins

help i cant do this

[en_US.composer.my_button_text]

# This function returns average size of all the burls in an array.

def averageSize(burls):
sum = sumSize(burls)
# Remember the average is the sum of the parts divided by the amount!
return sum / burls.length

# This function should return the sum of all the burls sizes.

def sumSize(burls):
# Implement the sum function using the burls ‘size’:
burlHealth = 0
enemies = hero.findEnemies()
for burls in enemies:
burlHealth += burl.health

while True:
# Find the average size of the burls by calling the ‘averageSize’ function

``````averageSize()
# Say the average size of the seen burls!
hero.say(averageSize)``````

Welcome to the Codecombat discourse.

This is the important line here. ‘size’ would translate to object.size, not object.health.
And when you use the averageSize() function in the while true loop, you need to set it to a variable then say the variable. e.g. myName = getMyName(hero.findNames()) hero.say(myName)
I hope this helps.

it has an error
it says: TypeError: Cannot read ‘property’ length of undefined

Make sure you put the ‘burls’ array in the brackets of the averageSize() function, otherwise you checking the averageSize of nothing.

this is my code:

# This function returns average size of all the burls in an array.

def averageSize(burls):
sum = sumHealth(burls)
# Remember the average is the sum of the parts divided by the amount!
enemies = hero.findEnemies()
for burl in enemies:
return sum / burls.length

# This function should return the sum of all the burls sizes.

def sumHealth(burls):
# Implement the sum function using the burls ‘size’:
burlHealth = 0
enemies = hero.findEnemies()
for burl in enemies:
burlHealth += burl.health
return burlHealth

while True:
# Find the average size of the burls by calling the ‘averageSize’ function

``````averageSize()
# Say the average size of the seen burls!
hero.say(averageSize)
``````

how do i format my code

Look at this topic: link, for formatting.

you still haven’t changed this section. Reread my posts above and see if you can figure it out.

my new code

``````def averageSize(burls):
sum = sumHealth(burls)
# Remember the average is the sum of the parts divided by the amount!
burls = hero.findByType("burl")
for burl in burls:
return sum / burls.length

def sumHealth(burls):
# Implement the sum function using the burls 'size':
burlHealth = 0
enemies = hero.findEnemies()
for burl in enemies:
burlHealth += burl.health
return burlHealth

while True:

averageSize()
# Say the average size of the seen burls!
hero.say(averageSize)]
``````

can you please show me a link for your posts

my hero says: [Function averageSize]

My posts are the ones above in this topic, ah well, I’ll tell you again.
Your problem’s still here:

look at this function:
`averageSize()` It needs to have something in the brackets () to use here:

You can use an array. e.g. hero.findEnemies(), you would put that value into a variable (enemies = hero.findEnemies()) then put that value into a function: damage = totalDamage(enemies).
Do you understand now?

``````
# But he doesn't know how big a Burleous Majoris would be...
# Find the average size of this burl population to use as a baseline.

# This function returns average size of all the burls in an array.
def averageSize(burls):
sum = sumHealth(burls)
# Remember the average is the sum of the parts divided by the amount!
burls = hero.findByType("burl")
for burl in burls:
return sum / burls.length

# This function should return the sum of all the burls sizes.
def sumHealth(burls):
# Implement the sum function using the burls 'size':
burlHealth = 0
enemies = hero.findEnemies()
for burl in enemies:
burlHealth += burl.health
return burlHealth

while True:
# Find the average size of the burls by calling the 'averageSize' function
enemies = hero.findEnemies()
burls = hero.findByType("burls")
burls = averageSize(burls)
averageSize(burls)

# Say the average size of the seen burls!
hero.say(averageSize)``````

never mind i solved it