The Hunt Begins- python


#1

def averageSize(burls):
sum = sumSize(burls)
return sum / len(burls)

def sumSize(burls):

sum = 0
for i in range(len(burls)):
    burl = burls[i]
    sum += burl.size
return sum

loop:
burls = hero.findEnemies()
avgSize = averageSize(burls)
hero.say(avgSize)

can someone tell me why this doesn’t work.
Thanks


#2

Maybe errors in averageSize

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

burls.length not len(burls)


#3

Ok thanks Rob, I’ll make the change and see if it works:):ok_hand:


#4

still saying the answer i get is wrong


#5

I don’t see anything wrong with your code. Try submitting the code instead of running it.


#6

keep running the code over and over
same thing for me too
i took like 20 submits to get it


#7

oops
(definitely 20 chars)


#8

ok thanks all. shall try and let you know


#9

submitted it 7 times and it worked. thank you so much


#10

I had the same problem. I couldn’t seem to get it to work no matter how many times I hit submit. I knew my code was right. It was the same code as I’ve seen posted in other topics about this level. I decided to try buying glasses with a longer range and as soon as I did that I succeeded immediately.

So my guess is that whichever glasses I had on didn’t have enough range to see all the burls that the correct answer expects. If anyone else is stuck on this level I’d recommend trying better glasses. Hopefully it will save you some frustration. I know I feel relieved to be past this level now.