How can I change the following code to include an else statement?
if 2 + ... == 4 ...
if 3 * ... == 9 ...
print ("if")
else:
print ("else")
This is what I have tried:
if 2 + 2 == 4 / 2
if 3 * 3 == 9 / 3
print ("if")
else:
print ("else")
However, I am getting a syntax error:
File "", line 1 if 2 + 2 == 4 / 2 ^ SyntaxError: invalid syntax
I don't think, it is useful to provide you a finished solution for your study task.
The if-statement line hast to end with a
:(as theelsedoes)But perhaps you also have a look at your maths think about the
else, to which 'if` it belongs to.Edit: By your answers I've got the impression, you're not watching for the correct intents.
The program skeleton is:
But your answer seems to have changed the skeleton code this way:
Please note the missing intent of the
elsein the second version! This little change changes the logic of the program and will prohibit a successful solution.