2 ответов
+ 4
The else clause needs to be on a separate line from the if statement.
+ 1
Jan S. ,
As Brian says.
I would also add that, by readability convention, even though not compulsory, you should put the "suite" of each "clause" on a separate line from the "header", and indent it four spaces.
# header of if clause
if (age) < 18:
# suite of if clause
print("Sorry! You must be at least 18 years!")
# header of else clause
else:
# suite of else clause
print("Congratulations, you have successfully verified your age!")
https://docs.python.org/3/tutorial/controlflow.html#if-statements
https://docs.python.org/3/reference/compound_stmts.html#compound-statements