#๐ Code review on a simple tic-tac-toe game for beginners
40 messages ยท Page 1 of 1 (latest)
@stark totem
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
!paste
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
https://paste.pythondiscord.com/IULQ
here is the code
sorry I couldn't paste the code here
why do you check_board at the start of every loop instead of just checking if someone won after they make a move?
also as a player i would rather input a coordinate rather than inputting the row and then the column
better yet, input an index
1-9
hmmm yeah didn't think of that but I think it will be the same logic, like our checking will be inside the function choose_tile or something like that, it will be similar I guess, I should check
the output would be the same but it would do it more efficiently
yeah I see, ok noted
yeah I found that confusing too
to keep the row length closer
will do that
use dots instead of underscores too
less visually noisy
no that wouldnt work because the . has a much shorter profile in width
would only work in a monospaced font
by the way, will checking the board after each move inside the function choose_tile itself will increase efficiency, because, at the end, aren't we doing the same thing, just instead of calling check_board in the function choose_tile at the end, we call it in the main itself but which is also after a player's move
i dont think lines 30 and 31 actually do anything
col = 0```
terminals already use monospaced fonts?
either way just ```
X . .
. . O
. . .
yeah true, I forgot to remove I think
oh i didnt know that, you right
any character will have same width in the terminal ? like and O and a . ?
yes
oh ok
you could add error checking to the input if you wanted
ValueError: invalid literal for int() with base 10: 'a'
yeah will do the handling of error/exceptions later on when I tackle the topic handling exceptions
game_board = [[0,0,0],
[0,0,0],
[0,0,0]]``` why store 0 when you could store `'_'`
which wouldnt require the later conversion
yeah at first, I wanted to build a "better" map using numbers to represent symbols but I gave up that idea for now
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.