in python no brace so how do we distinguish the end of the while loop? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

in python no brace so how do we distinguish the end of the while loop?

7th Sep 2016, 11:56 PM
Dumadi Lesi
Dumadi Lesi - avatar
5 Answers
+ 2
by the concept od indentation every line in the loop must be indented and the lines outside the loop won't be indented for ex x=5 y=8 while x<y d=x/y g=x*y f=x%y print('i am outside the loop')
8th Sep 2016, 12:41 AM
Moataz el-tahan
Moataz el-tahan - avatar
+ 1
Statements/commands that are controlled by a while, if, for must have same indentation. The break is used to exit the loop on any point inside the loop, but it is not required in order to end the loop, it depends on your logic.
8th Sep 2016, 12:45 AM
Luis Eduardo Bravo de Moura
Luis Eduardo Bravo de Moura - avatar
0
You must indentation.
8th Sep 2016, 12:34 AM
Luis Eduardo Bravo de Moura
Luis Eduardo Bravo de Moura - avatar
0
thanks but..in simple calculator example..one big indentation but break statement is used thereafter
8th Sep 2016, 12:38 AM
Dumadi Lesi
Dumadi Lesi - avatar
0
thanks
8th Sep 2016, 12:43 AM
Dumadi Lesi
Dumadi Lesi - avatar