How can we know the body of while is end there is no bracket to tell us? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How can we know the body of while is end there is no bracket to tell us?

7th Apr 2019, 2:04 AM
Aditya Verma
Aditya Verma - avatar
4 Answers
+ 3
By looking at the levels of indentation. Statements within the same block of code need to be indented at the same level. for i in range(42): while True: print(i) break print(42) # Same level of indentation as the while loop
7th Apr 2019, 2:16 AM
Diego
Diego - avatar
+ 3
Something like this. if n==0: # Level 0, no indentation if n==1: # Level 1 if n==2: # Level 2 ... else: # Level 2 ... else: # Level 1 ... else: # Level 0 ...
7th Apr 2019, 2:24 AM
Diego
Diego - avatar
0
Level of indentation?
7th Apr 2019, 2:17 AM
Aditya Verma
Aditya Verma - avatar
0
Thanks
7th Apr 2019, 2:24 AM
Aditya Verma
Aditya Verma - avatar