Code will not execute

Dear forum,
When I try to run the following code, I get this error message:

‘expected an indented block after “if” statement on line 9’. The ‘e’ in ‘else:’ is highlighted

#Initialize variables

count = int(input("Enter the count "))
total = int(input("Enter the total "))

if count > 0 and total // count > 0:
    # the code to compute and print the result goes here
else:
    print("Error: both conditions must be met.")

Any suggestions would be welcome.

I did indent four spaces after the ‘if’ statement and after the ‘else’ statement in the original code.

A comment is not a valid statement.

You need an actual Python statement. Include a pass keyword as a space filler for now or add an actual statement (i.e., print(‘Print statement for now until I figure out what I want to include here’)).

By the way:

Also, the string in the print is missing a closing ".

Thanks for the reply. Followed your suggestions and I think I have a post now that can be understood more clearly. Please look at it again.

Thanks for the input. I had included the closing quotation marks in the original code but overlooked it in the post. Went back and edited the post again and included it.

If your code still doesn’t work, insert a pass statement under the comment with the same indentation level. That should function as a placeholder for the code I assume you haven’t written yet

Thanks. I’ll look into that if the problem persists.

Tried the pass statement and code executed properly. Thanks again.

1 Like