tic tac toe assignment in Python 3.3.5

389 views Asked by At

I'm almost done with an assignment to make a tic-tac-toe game, but for the life of me I can't work through an error I'm encountering in it upon execution. Any advice would be immensely appreciated.

Code link: http://pastebin.com/k7deVCAD

error upon execution:

Traceback (most recent call last): File "C:/Users/Andrew/Dropbox/program2.1.py", line 168, in I_hope_this_works ()

File "C:/Users/Andrew/Dropbox/program2.1.py", line 145, in I_hope_this_works play (player_names, player_marks)

File "C:/Users/Andrew/Dropbox/program2.1.py", line 154, in play askUserToPlayNextMove (player_names['X'], player_marks) #asks them to input move File "C:/Users/Andrew/Dropbox/program2.1.py", line 52, in askUserToPlayNextMove (row, column)= input("Please input your next move in row, column format ")

ValueError: too many values to unpack (expected 2)

2

There are 2 answers

1
lanpa On

The function

askUserToPlayNextMove (currentPlayer, player_marks)

needs two arguments, but you passed them as a single tuple:

askUserToPlayNextMove ((player_names['X'], player_marks))

try this:

askUserToPlayNextMove (player_names['X'], player_marks)
0
Nwilson On

I think the issue is just that you have an extra set of parenthesis when calling the function "askUserToPlayNextMove."

You have the function call as:

askUserToPlayNextMove ((player_names['X'], player_marks))

and I think simply changing it to:

askUserToPlayNextMove (player_names['X'], player_marks)

will solve your problem. When you put the extra set of parenthesis around the arguments in the function call, it interprets the data inside of those parenthesis as corresponding to one of the parameters in the function. Removing the extra set will pass those arguments as two separate arguments instead of one.