Python Forum
syntax error on return statement - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: syntax error on return statement (/thread-27248.html)



syntax error on return statement - l_butler - May-31-2020

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)



RE: syntax error on return statement - menator01 - May-31-2020

Please post the entire error in appropriate tags.


RE: syntax error on return statement - l_butler - May-31-2020

Issue solved! missing bracket


RE: syntax error on return statement - pyzyx3qwerty - May-31-2020

What do you mean, missing bracket - return statements don't have brackets, do they?


RE: syntax error on return statement - buran - May-31-2020

(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


RE: syntax error on return statement - pyzyx3qwerty - May-31-2020

Thanks buran