Given that board is a function then I believe that it is likely you're
either (a) doing something wrong beforehand, or (b) if board is a
function that generates the Tic Tac Toe board, then the syntax you more
likely need is board()[number] , but I can't be completely certain.
when I say doing something wrong beforehand, I'm thinking you might be
accidentally giving the funtion a new name, instead of assigning it's
return value to a variable,
like so:
newname = functionname //see here, no brackets on the end of the
function, this basically tells python that newname is also functionname.
variable = functionReturningValue() //and here, the function's return
value is obviously being assigned to the variable
Disclaimer: My naming scheme sucks, I know this :)
Cheers
--Brett
John Fouhy wrote:
2009/3/9 WM. <wfergus...@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.
_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor