0

What is intend whether it is spaces

Python 3

1st Sep 2017, 2:05 PM
corejava
8 ответов
+ 5
@corejava: It's not 'inTenD' but 'inDentT'..., and 'indent' in Python is same as in any other computer language, spaces used to shift lines content and make code easier to read/understand. In python, the specificity is that 'indentation' is mandatory, contrarly to most of others syntax wich doesn't require code to be 'indented', but where it's anyway a good and useful practice. For example compare this two ways of writting html code: <!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> Content </body> </html> <!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <p>Content</p> </body> </html> ... You can quickly see the structure of the document in the second one ;) In a Python code, this is the only way to tell to the interpreter where start and end blocks (groups) of code, where others languages commonly used curly brackets to delimit them)... compare this two ways of writing Python code: for i in range(10): print('iteration:',i) print('loop ended') for i in range(10): print('iteration:',i) print('loop ended') ... In the second (invalid) way, it's impossible to tell if the second print statement is 'intended' (yes, not 'indented': 'expected' or 'attended' in this case, that's two different meaning ;P) to be included in the loop body ^^
1st Sep 2017, 2:48 PM
visph
visph - avatar
1st Sep 2017, 2:49 PM
Hatsy Rei
Hatsy Rei - avatar
+ 2
You've marked as best one my answer, and then removing it (and set best answer mark on @Michelle post)... are you really convinced that my answer doesn't deserve it? @@
1st Sep 2017, 3:05 PM
visph
visph - avatar
+ 1
thank u all
1st Sep 2017, 3:00 PM
corejava
+ 1
sorry that was network problem I pressed twice that's y I'm satisfied with ur answers
1st Sep 2017, 3:18 PM
corejava
0
yes what is intended in python
1st Sep 2017, 2:10 PM
corejava