[Tutor] function error
Alan Gauld
alan.gauld at btinternet.com
Tue Sep 28 12:09:12 CEST 2010
"roberto" <roberto03 at gmail.com> wrote
> i have the following error when i call this function:
> 20 def outOfBounds():
> ---> 21 if abs(turtle.position()[0]) >
> turtle.window_height()/2 or abs(turtle.position()[1]) >
> turtle.window_width()/2:
> 22 return "true"
> 23 else:
>
> TypeError: 'function' object is unsubscriptable
>
> but i can't really figure out where is the problem with this
> function
> 'unsubscriptable';
This means you are trying to use [] on a function.
eg you might be doing turtle.position[1] instead of
turtle.position()[1]
I can't see it in your code sample but I'd check carefully that your
parens() all balance correctly and are in the right place...
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
More information about the Tutor
mailing list