+ 1
Why does this give me an error?
if 1 + int(input("enter a number: ")) == 2: if 1 + 2 == 3: print(True)
3 Answers
+ 12
if (1 + int(input("enter a number: "))) == 2:
print(True)
else:
print(False)
Fixed.
+ 7
Hi, Abbie! I think this is because of the second if block, just because of it does nothing. Because boolean for 1+2==3 is True, so writing if true: means nothing. The problem here is that Python is very indent sensitive language, so you should have either removed the second if statement or (if you for some reason need to keep it) removed the empty line (line 3) and add tabulation (indent) before print line
+ 1
Or
num = int(input("enter a number: "))
if 1 + num == 2:
if 1 + 2 == 3:
print(True)
else:
print (False)
else:
print(False)
I don't know what is the logic u trying to build (r u tring nested if )
One more thing, Use variables it helps u to write readable code and avoid confusion.