Python Forum
syntax error on return statement
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
syntax error on return statement
#1
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)
Reply
#2
Please post the entire error in appropriate tags.
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
Gaming Collection
Homepage
my-python
Reply
#3
Issue solved! missing bracket
Reply
#4
What do you mean, missing bracket - return statements don't have brackets, do they?
pyzyx3qwerty
"The greatest glory in living lies not in never falling, but in rising every time we fall." - Nelson Mandela
Need help on the forum? Visit help @ python forum
For learning more and more about python, visit Python docs
Reply
#5
(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
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#6
Thanks buran
pyzyx3qwerty
"The greatest glory in living lies not in never falling, but in rising every time we fall." - Nelson Mandela
Need help on the forum? Visit help @ python forum
For learning more and more about python, visit Python docs
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Heart near "(": syntax error Maryan 1 162 Jun-09-2021, 02:29 PM
Last Post: Yoriz
Exclamation getting a syntax error and i don't know why ilikedofs 10 565 May-13-2021, 08:52 PM
Last Post: deanhystad
  Even number code syntax error MrCeez 1 259 May-02-2021, 06:43 PM
Last Post: Larz60+
  error in your SQL syntax Xuli 10 463 May-02-2021, 12:27 PM
Last Post: Xuli
  Function syntax error Changosoyyo 2 412 Mar-07-2021, 10:42 PM
Last Post: Changosoyyo
  Syntax error on line 29 manwithjeans 3 463 Feb-27-2021, 08:28 AM
Last Post: perfringo
  Invalid syntax error - need help fixing calgk01 3 518 Feb-23-2021, 08:41 PM
Last Post: nilamo
  Why do I get Syntax error? TechNitium 1 354 Jan-22-2021, 12:49 PM
Last Post: snippsat
  syntax error CompleteNewb 8 649 Jan-08-2021, 04:05 PM
Last Post: deanhystad
  Syntax Error: Outside a function? aplusfordao2702 2 461 Dec-01-2020, 03:25 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020