Syntax Error


Hello everyone,

I followed the steps and concluded the Battleship game but when i copy and paste the code into the Python IDLE, to play it in my computer :), i got "Syntax Error: Invalid Syntax". Does anyone have any idea what's going on there?


Hi, @scriptmaster74630 ,

When you ported the code to Python 3, did you convert all the print statements to function calls by placing parentheses around the information to be output?

For example, this ...

def print_board(board):
    for row in board:
        print " ".join(row)

... should be revised to this for execution in Python 3 ...

def print_board(board):
    for row in board:
        print(" ".join(row))

For Python 3, you also need to change raw_input to input.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.