#πŸ”’ It doesn't want to run my code.

15 messages Β· Page 1 of 1 (latest)

outer venture
#

i use microsoft visual studio code. im spamming the run botton and it doesnt want to work . no errors show up and the code only works without this part:
def counter():

def winner():
    if "X" == 3 :
        print("X wins")
    elif "O" == 3 :
        print ("O wins")

grid[:12].count("X")
grid[:12].count("O")
winner()
grid[12:25].count("X")
grid[12:25].count("O")
winner()
grid[25:].count("X")
grid[25:].count("O")
winner()

while True :
counter()

here is the full version:

grid = '''
.\t.\t.




.\t.\t.





.\t.\t.'''
print(grid.expandtabs(14)[:30])
def counter():
    
    def winner():
        if "X" == 3 :
            print("X wins")
        elif "O" == 3 :
            print ("O wins")
    
    grid[:12].count("X")
    grid[:12].count("O")
    winner()
    grid[12:25].count("X")
    grid[12:25].count("O")
    winner()
    grid[25:].count("X")
    grid[25:].count("O")
    winner()
while True :
    counter()

dont question the code i just didnt work on it much

hazy solarBOT
#

@outer venture

Python help channel opened

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.

elder surge
#

well... the code needs to be questioned, because as it stands, it's to be expected that it doesn't output anything

#

at least other than the print(grid.expandtabs(14)[:30]), which you didn't have in the version you posted to #python-discussion ...

#

for starters, "X" == 3 will never be True, and same for "O" == 3, which means your winner function can't print anything

grand sinew
#

Note that those calls to count() aren't doing anything since yonever save the result anywhere. Also, the string X will never be equal to the integer 3. I think you meant to call count there.

elder surge
#

you also don't take any user input, so the state of the board doesn't change

elder surge
outer venture
#

ok then how to stop it

elder surge
#

Ctrl+C in the terminal

outer venture
#

mabe ill just delete it and save it in a note then work on replacing the dots

hazy solarBOT
#
Python help channel closed

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.