[Tutor] UNSUBSCRIPTABLE?

John Fouhy john at fouhy.net
Sun Mar 8 22:27:08 CET 2009


2009/3/9 WM. <wferguson1 at socal.rr.com>:
>  File "C:\Python26\TicTacToeD.py", line 68, in DisplayBoard
>    print "\n\t", board[1], "|", board[2], "|", board[3]
> TypeError: 'function' object is unsubscriptable
>
> I am fooling around with Dawson's "...for the Absolute Beginner". The
> tic-tac-toe program will not run for me. I'm guessing a typi somewhere, but
> cannot find it.

"subscript" means "a thing in square brackets after a name".  You've
got three subscripts in that line: board[1], board[2], and board[3].

The error means that you're trying to use square brackets after
something that doesn't support them.  It's telling you that 'board' is
a function (as opposed to a list or a dict, for example) and functions
don't support [].

Possibly you're meant to call board:

    print "\n\t", board(1), "|", board(2), "|", board(3)

Or, alternatively, you may have assigned to it by mistake somewhere.

-- 
John.


More information about the Tutor mailing list