You have two independent if
statements. That the second such statement has an else
suite doesn’t matter here; that else
suite is picked on the basis of the condition attached to the second if
test; whatever happened in the first if
statement doesn’t matter.
If you want the two x
tests to not be independent, use one if
statement and use an elif
suite for the second test:
if x == 3:
test="True"
elif x == 5:
test="False"
else:
test="Inconclusive"
The elif
here is part of the single if
statement, and now only one of the three blocks is executed.
0
solved Python second “if statement” negates first one