What's the difference between the for loop contain a statment inside the loop with curly braces and without the curly braces | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What's the difference between the for loop contain a statment inside the loop with curly braces and without the curly braces

11th Dec 2021, 4:10 PM
Harikumar M
2 Answers
+ 2
Not clear question..??? Example? If you have single statement in loop, you can skip to put braces otherwise you should use braces. If you ommit braces then next single statement will be considered as belong loop..
11th Dec 2021, 4:14 PM
Jayakrishna 🇮🇳
+ 1
Harishiva For single line statement no need of curly braces but for multi line statement within a block we need. Python doens't have curly braces so we need to indent code inside block otherwise second line statement will be considered as outside the block.
11th Dec 2021, 4:22 PM
A͢J
A͢J - avatar