I need help with Indention errors it doesn't make sense 😢

Print("What is 1 Plus 1?")
if input() == 2:
Print("Correct")
If input() != 2:
Print("Wrong!")

Please Help Me! I need it very much it’s super dumb and frustrating

Don’t use capital letters for print() and if commands.
For indentation, use at least 1 space before commands within an if statement.
Also, after the if statement, use elif.
You might find this page from W3Schools helpful.

4 Likes

Could you un-solution that, by chance? (Your question hasn’t really been answered yet, and people might be discouraged from replying because it seems like you got an answer)

3 Likes

There are quite a few errors but as I smell homework here I am not going to write the code, but just tell you where you can find the errors:

  • you need to ask the answer only once
  • you need to compare apples with apples …
3 Likes

I kinda did too, so I’ve just edited my post.

I hope OP didn’t see the code I posted

1 Like

Well first of all you don’t use capital Print in python, it’s just lowercase.
Most indentation errors come are caused by mixing tabs and spaces for indentation, so choose one and stick with it. To fix the problem most editors can convert tabs to spaces or vice versa, just google how to do that for your particular editor.

Your code is also isn’t going to work as you are asking for the input twice, instead you should store it in a variable and then check it’s value with the if statements.
You also don’t need to check if it’s not equal to two, just use else, and finally, input() returns a string, which can’t be compared with an number (an integer) so you need to convert it to an integer with int()

print("What is 1 + 1?")

# return the value of input into answer
answer = int(input("> "))

# check if answer is equal to 2
if answer == 2:
    print("Correct!")
# use else to catch any value is that is not equal to 2
else:
    print("Incorrect")

Note: I indented with with 4 spaces. I suggest you use spaces as that’s what most people use

2 Likes

Technically, 1 space works

2 Likes

Please pay check if this was an homework before giving a full solution. Too late now.

4 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.