Why do I get a syntax error? – Python [on hold]

Why do I get a syntax error at if i % 2 == 0, line 9? I am decent at Java, but just started transferring to python so not sure if I made a stupid mistake.

EDIT: To be more clear it says – TabError: inconsistent use of tabs and spaces in indentation

EDIT: SOLVED PLEASE IGNORE. Error was due to mix of space and indentations in Python 3

tic = TicTacToe()
print ( "Welcome to Tic Tac Toe!" )
play = "yes"
while play == "yes" or "Yes":
    print (tic.drawGrid())
    for i in range(1,10): 
        print ("Turn " + i)

        if i % 2 == 0:
            tic.setPlayer (" O ")
        else:
            tic.setPlayer (" X ")

        hasWon = "";
        print ("Player" + tic.getPlayer() + ": ")
        y = input("Y coordinate: ")
        print ("n")
        x = input("X coordinate: ")

        if tic.checkGrid(y, x) == false:
            print ( "Invalid input." );
            i -= 1;
            continue;

        tic.setGrid ( y, x );
        print ( tic.drawGrid() + "n" )
        hasWon = tic.checkResult();

        if hasWon != "":
            print ( hasWon )
            break;

        if i == 8:
            print ("It's a tie!" )

    play = input("Would you like to play again?")


Source: syntax

Leave a Reply