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 Scripts
CookBook - Shmup - PyQt5 Music Player


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
Star I'm getting syntax error while using input function in def. yecktmpmbyrv 1 204 Oct-06-2021, 09:39 AM
Last Post: menator01
Exclamation Invalid syntax error(Predict Ethereum Price) lulu43366 2 299 Sep-24-2021, 01:24 PM
Last Post: lulu43366
  Line 42 syntax error..Help!!1 patpython 4 384 Sep-01-2021, 03:22 PM
Last Post: deanhystad
  Unexplained Invalid syntax Error cybertooth 5 474 Aug-02-2021, 10:05 AM
Last Post: cybertooth
  How to invoke a function with return statement in list comprehension? maiya 4 553 Jul-17-2021, 04:30 PM
Last Post: maiya
  I have a syntax error! rohes_kaugummi 3 656 Jun-23-2021, 05:24 PM
Last Post: deanhystad
  import module with syntax error Skaperen 7 767 Jun-22-2021, 10:38 AM
Last Post: Skaperen
Heart near "(": syntax error Maryan 3 907 Jun-21-2021, 08:05 AM
Last Post: ibreeden
Exclamation getting a syntax error and i don't know why ilikedofs 10 1,293 May-13-2021, 08:52 PM
Last Post: deanhystad
  Even number code syntax error MrCeez 1 668 May-02-2021, 06:43 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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