Python Forum

Full Version: syntax error on return statement
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
The code below is for checking if there is a winner in a game of tic tac toe. I am getting a syntax error on the return line, with "return" being highlighted. Could someone explain to me why?

def winner(board):
	for mark in [X,O]:
		if board[0][0]==board[0][1]==board[0][2]== mark or board[1][0]==board[1][1]==board[1][2]==mark  or \
		board[2][0==board[2][1]==board[2][2]== mark or board[0][0]==board[1][0]==board[2][0]== mark or \
		board[0][1]==board[1][1]==board[2][1]== mark or board[0][2]==board[1][2]==board[2][2]== mark or \
    	board[0][0]==board[1][1]==board[2][2]==mark or board [0][2]==board[1][1]==board[2][0]==mark:
    		return "{} is the winner".format(mark)
Please post the entire error in appropriate tags.
Issue solved! missing bracket
What do you mean, missing bracket - return statements don't have brackets, do they?
(May-31-2020, 11:47 AM)pyzyx3qwerty Wrote: [ -> ]What do you mean, missing bracket - return statements don't have brackets, do they?
sometimes error is on the previous line than the one indicated in the traceback. In this case there is missing bracket on line#4
Thanks buran