Hi, I have 2 sets of codes for this level, in my opinion, both sets should work and have the same result, but unfortunately, the second one doesn’t give me the right answer, can you have a look and help me with it ? thanks
yetis = hero.findByType("yeti")
# Implement the averageSize function from scratch:
def averageSize(enemies):
sum = 0
for i in range(len(enemies)):
enemy = enemies[i]
sum += enemy.size
return sum/enemies.length
# Say the average size of the yetis:
avgSize = averageSize(yetis)
hero.say(avgSize)
yetis = hero.findByType("yeti")
# Implement the averageSize function from scratch:
def averageSize(enemies):
sum = 0
for enemy in enemies:
sum += enemy.size
return sum/enemies.length
# Say the average size of the yetis:
avgSize = averageSize(yetis)
hero.say(avgSize)