Pls help | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
2 Answers
+ 4
The else clause needs to be on a separate line from the if statement.
24th Apr 2024, 12:35 AM
Brian
Brian - avatar
+ 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
24th Apr 2024, 12:41 AM
Rain
Rain - avatar