0

Hello, I've been programming for 3 weeks and this is my first milestone project.

I was trying out a template for an interactive tic-tac-toe game. What I want to do is format the empty board with X's and O's from a list that is filled by user input.

emptyboard = """
    {1} | {2} | {3}
    ____|_____|____
    {4} | {5} | {6}
    ____|_____|____
    {7} | {8} | {9}
        |     |"""
print(emptyboard)
print(emptyboard.format(["#","X","O","O","O","O","X","X","X","X"]))

And I get an IndexError, yet I think that I have enough values in both my table and string formatting method. Output:

    {1} | {2} | {3}
    ____|_____|____
    {4} | {5} | {6}
    ____|_____|____
    {7} | {8} | {9}
        |     |
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-22-4c3674aa4a8b> in <module>
      7         |     |"""
      8 print(emptyboard)
----> 9 print(emptyboard.format(["#","X","O","O","O","O","X","X","X","X"]))

IndexError: tuple index out of range

Thanks in advance to everyone who tries to help! I will look up other ways of coding the game, but I'm just curious what my mistake is!

0 Answers0