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.
My Github
How to post code using bbtags


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
  Syntax error for "root = Tk()" dlwaddel 15 1,011 Jan-29-2024, 12:07 AM
Last Post: dlwaddel
Photo SYNTAX ERROR Yannko 3 334 Jan-19-2024, 01:20 PM
Last Post: rob101
  An unexplainable error in .format statement - but only in a larger piece of code? ToniE 4 656 Sep-05-2023, 12:50 PM
Last Post: ToniE
  Receiving this error in my "response" and causes script to return wrong status cubangt 18 1,909 Aug-13-2023, 12:16 AM
Last Post: cubangt
  Syntax error while executing the Python code in Linux DivAsh 8 1,451 Jul-19-2023, 06:27 PM
Last Post: Lahearle
  Code is returning the incorrect values. syntax error 007sonic 6 1,136 Jun-19-2023, 03:35 AM
Last Post: 007sonic
  syntax error question - string mgallotti 5 1,251 Feb-03-2023, 05:10 PM
Last Post: mgallotti
  Syntax error? I don't see it KenHorse 4 1,194 Jan-15-2023, 07:49 PM
Last Post: Gribouillis
  Syntax error tibbj001 2 847 Dec-05-2022, 06:38 PM
Last Post: deanhystad
  Need help with Return statement Columbo 13 2,179 Sep-17-2022, 04:03 PM
Last Post: Columbo

Forum Jump:

User Panel Messages

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