why cant i use break it says invalid syntax. Whats wrong with it? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

why cant i use break it says invalid syntax. Whats wrong with it?

ash = 78 wood = 9 lucky = 569 while ash <= 162839: print(ash) ash = ash * 3 if ash >= 82929: break while wood <= 82919731927: print(wood) wood = wood ** 2 if wood >= 71991011: break while lucky <= 728173739291193773829177192729: print(lucky) lucky = lucky * 81920281728 if lucky > 666666666666662772717819: break

25th Oct 2017, 12:19 AM
haijust1
2 Answers
+ 6
Incorrect indentation. ash = 78 wood = 9 lucky = 569 while ash <= 162839: print(ash) ash = ash * 3 if ash >= 82929: break while wood <= 82919731927: print(wood) wood = wood ** 2 if wood >= 71991011: break while lucky <= 728173739291193773829177192729: print(lucky) lucky = lucky * 81920281728 if lucky > 666666666666662772717819: break You need to indent the code you want to run for the if statement..
25th Oct 2017, 12:23 AM
ChaoticDawg
ChaoticDawg - avatar
0
check your indention... as c java works with { } we seem to hav a clear idea of which block of code in which loop or if else etc.. but in python it works with indention if a==b : do this else : if i<j: do that
25th Oct 2017, 5:10 AM
sayan chandra
sayan chandra - avatar