Python course hel needed indentation couldn't understood it | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Python course hel needed indentation couldn't understood it

Python uses indentation (white space at the beginning of a line) to delimit blocks of code. Other languages, such as C, use curly braces to accomplish this, but in Python indentation is mandatory; programs won't work without it can anyone give some example how they are used...

19th Mar 2017, 8:02 PM
k.prithviraj murty
k.prithviraj murty - avatar
2 Answers
+ 1
As you said, some languages use braces. Braces like indentations define blocks of code. You can imagine using the "TAB" button instead of these braces to define your blocks, so if in C# you have public int Funct(int x) { return x; } in python you would simply have def Funct(x): return x Or: public int Funct() { int x = 0; for (int i = 0; i<10; i++) { x+=1; } return x; } in python it would look something like def Fucnt() x=0 for i in range(0, 10): x+=1 return x So the "def" is the first block of code, then the "x", "for" and "return" statements are the second block (indented by one) and "x+=1" line is the third block. You can read more about it here: http://www.python-course.eu/python3_blocks.php Hope this helped. Happy coding!
19th Mar 2017, 8:25 PM
superdarkec
superdarkec - avatar
0
thanks for the clear explanatio...much appreciated
19th Mar 2017, 8:31 PM
k.prithviraj murty
k.prithviraj murty - avatar