+ 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
2 Answers
+ 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