Confused with while/if line | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Confused with while/if line

So i’m writing a line of code: if (name == 'Joshua' and age == 18): i = 1 while i <= 5: print(i) i = i + 1 if i == 5 print("Finished") Yes this is taken from a lesson with me adding onto it; When I attempt to run the code, it says there’s a syntax error at “if i == 5” Why is it not letting me only print “finished” if i == 5? Am I misunderstanding something? Thanks

26th Feb 2022, 11:52 PM
Joshua Moore
Joshua Moore - avatar
1 Answer
+ 3
Answer, I simply forgot the colon I realized after attempting to solve this for 20 minutes right after posting this question. Sorry
26th Feb 2022, 11:54 PM
Joshua Moore
Joshua Moore - avatar