Why is hero.say(enemies) not possible?

enemies = hero.findEnemies()
hero.say(enemies)

What is this Error:Attempted to invoke bookmark for [Function]?

I believe it’s because the method hero.say was expecting a string or a function. Normally, the word, enemies, would be in quotation marks like this:

hero.say("enemies")

in which case the character would literally say the word, “enemies”.

Since it is not in quotation marks, the code was expecting a function to be called, only you haven’t defined a function called enemies.

def enemies():
    # tab over and code goes here

Someone please correct me if I’m wrong about this.

def enemies():
        hero.say("Programming with Yeti")
hero.say(enemies) #[Function enemies]

I believe the method hero.say expect a string or a variable.

The hero.say function expects string or number as the input, while “enemies” is an array. You’ll have to iterate through the array if you want the hero to say each of the enemy’s id.

I thought hero.say works similar to print:

#!/usr/bin/python

list = [1, 2, 3, 4, 5, 6, 7 ];
print "list[1:5]: ", list[1:5]

When the above code is executed, it produces the following result −

list[1:5]: [2, 3, 4, 5]

It’s just a bug in our interpreter with saying arrays of objects that have custom toString methods. Rob knows about it and will fix it when he gets down to the medium-priority bugs. :wink:

Javascript Interpreter is OK.
var a=[1,2,3];
hero.say(a);

When the above code is executed, it produces the following result −
1,2,3