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
For indentation, use at least 1 space before commands within an
Also, after the
if statement, use
You might find this page from W3Schools helpful.
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)
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 …
I kinda did too, so I’ve just edited my post.
I hope OP didn’t see the code I posted
Well first of all you don’t use capital
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
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
Technically, 1 space works
Please pay check if this was an homework before giving a full solution. Too late now.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.