[Tutor] exercise problem

Walter Prins wprins at gmail.com
Fri Aug 27 17:20:27 CEST 2010


Hi Roelof,

See below

On 27 August 2010 16:05, Roelof Wobben <rwobben at hotmail.com> wrote:

>
> uitkomst = add_vectors[u,v]
>
> But now I get this error message :
>
>
> Traceback (most recent call last):
> *File "C:\Users\wobben\workspace\oefeningen\src\test.py", line 27, in
> <module>*
>
> uitkomst = add_vectors[u,v]
>
> TypeError: 'function' object is not subscriptable
>
>
>
> So it seems that I can't use vectors as a variable in a function.
>
Carefully compare the syntax for calling your function (as in the doctest)
to what you've written above.  See the difference?  (Hint: check the type of
parentheses...)

The error message is giving you a hint -- a subscriptable item is something
like a list or array.  They use square brackets.  Function calls always use
(round) parentheses.  To python, it looks like you're trying to subcript the
function object "add_vectors", which obviously isn't possible.  Hence the
message.

Regards,

Walter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100827/e25c57d9/attachment-0001.html>


More information about the Tutor mailing list