0

Here's my code:

import numpy as np

def create_board():
    board = np.zeros((6, 7))
    return board

board = create_board()
game_over = False

while not game_over:
    # Ask for player 1 input
    # 3 errors: Expected indented block, expected expression, and statements must be seperated by newlines or semicolons

Why am I getting these errors? Is it because of the "while not game_over" loop? I put an indented block too! It's too hard to figure out!

3
  • We can't answer this without the code that actually raise those errors. Commented Jan 16, 2022 at 12:21
  • Right now your code produces an error because you open a loop without anything in it. you open an empty block, which is wrong. Commented Jan 16, 2022 at 12:22
  • Your indented block needs to contain actual code, not just comments. If you have nothing else to put there, put pass or ... (though then what's the point of the block?) Commented Jan 16, 2022 at 12:23

1 Answer 1

0

Python expects an (indented) statement after a while. You only have comments (denoted with #) there, which are removed when Python runs the program. As a result, Python interprets this program to not have an indented statement after the while.

One solution is to add pass, which does nothing in Python, but satisfies the condition that there is some statement after a while ...:. You can replace this pass with the actual program once you get around to writing it. This pass is essentially a temporary measure to keep Python from complaining.

import numpy as np

def create_board():
    board = np.zeros((6, 7))
    return board

board = create_board()
game_over = False

while not game_over:
    # Ask for player 1 input
    # 3 errors: Expected indented block, expected expression, and statements must be seperated by newlines or semicolons
    pass

That is the only error I can see. Please update your question to include the errors you are experiencing if you want people to be able to help you.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, I figured this exact solution out before you even answered! Thank you again!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.