7

void main() is not portable Although it "works" in a lot of cases, the only two portable definitions of main are: int main(void) and int main(int argc, char **argv) Error checking You don't check the return value of scanf. This would be better: if(scanf("%d", &n) != 1) { fputs("Error; enter a number.", stderr); return EXIT_FAILURE; /* ...


5

First of all, I suggest you read pep8 (https://pep8.org/). I see you have violations. Understanding pep8 is a must if you want to be a pro Python developer. Better yet, use flake8 to automatically find pep8 violations in your code. Second, using that many elif statements is always a red flag, especially when they seem to be doing the same thing. Can you ...


3

In no particular order: Comments on what the variable names represent would be helpful, if for no other reason than to encourage more thought about your data model -- if it's hard to describe what each variable contains, maybe there's a way to store your data that's less confusing? p1 and p2 look like static values, so I'd suggest making them class ...


3

Ways of improving/optimizing: draw_board function. prefer enumerate(board) over redundant list(range(len(board))) all conditional branches within for loop have the same common expression to append ' ' + str(board[number]) + ' '. Thus, it can be moved up to reduce conditional branches prefer flexible f-string formatting over awkward string concatenation ...


2

check_win There are a lot of if and elif statements here. You can reduce this by utilizing python's any built in function. This will return True if any of the values passed in are True. And since you have a bunch of expressions that evaluate to boolean values, this can be rewritten like so: def check_win(board, letter): return any([ (item ==...


2

Your code can have many improvements. Fixing the bugs 0 1 2 3 4 5 6 7 8 Input number 0 to 8 asd Input number 0 to 8 asd Input number 0 to 8 0 ⭕ 1 2 3 4 5 6 7 8 Input number 0 to 8 1 ⭕ ❌ 2 3 4 5 6 7 8 Input number 0 to 8 2 ⭕ ❌ ⭕ 3 4 5 6 7 8 Input number 0 to 8 3 ⭕ ❌ ⭕ ❌ 4 5 6 7 8 Input number 0 to 8 4 ⭕ ❌ ⭕ ❌ ⭕ 5 6 7 8 Input number ...


2

As others have mentioned, python has a style guide, PEP8. It's very useful for yourself and people reading your code if you follow this guide as it makes your code consistent, readable and idiomatic. You have some typos and warnings in your code which show up immediately in my editor. It's worth looking at using an IDE to see these while you're writing. ...


Only top voted, non community-wiki answers of a minimum length are eligible