DEV Community

Discussion on: tic tac toe(python 2)

Collapse
 
curtisfenner profile image
Curtis Fenner

I have some feedback on your code!

First, Python 2 is no longer supported. You should really try to use Python 3 as much as possible, because after a few months Python 2 will no longer receive any security updates, etc.

There's a couple places where your code isn't formatted properly (e.g., spaces before :, using two spaces for indentation in some places and one space in others). You should be using an auto-formatter on-save so that you don't have to worry about getting this right, but still ensure that it's always right.

A break after a return isn't necessary, because return exits out of the whole function.

Your check_rows() doesn't look right. The first if uses is in the indexes, but the second one doesn't, and the else also having a return means that your for loop will never get past its first iteration. (Same goes for check_column)

Also, just checking all three in a row/column/diagonal are == is too generous of a check, since "-" == "-"! You probably want to check that all three are equal to a player's symbol, instead of just equal to each other.

You don't need to say == True; you could say if player_won_diagonal or player_won_column or player_won_row:

Collapse
 
fragiskosfarmakis profile image
Fragiskosfarmakis

Thank you very much for the feedback,I really appreciate it.