+ 1

I don't understand the indentation . How to do it

27th Aug 2017, 10:22 AM
geethika geeths
geethika geeths - avatar
6 ответов
+ 17
This is not indented. This is indented. This is also indented. Indented at same level as line 3. This is not indented.
27th Aug 2017, 10:28 AM
Hatsy Rei
Hatsy Rei - avatar
+ 13
spacebar or tab
27th Aug 2017, 11:55 AM
Ahri Fox
Ahri Fox - avatar
+ 11
You just need to remember to indent the lines of code constituting a logical block. The indentation jump has to be consequent throughout the code. Whenever you have a block of code like method definition, loop or if/else statement, you make an indent and if it is nested, you make another indent each time it is needed. For example: def my_func(x): # no indentation if x == 3: # one indentation jump, I chose 4 spaces print(x) # two jumps, so 8 spaces altogether else: # back to one-indentation jump print(2) # again two jumps, as this is a logical subblock of code in the if/else statement
27th Aug 2017, 10:28 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 10
I suggest Tab ↔️
31st Aug 2017, 7:34 AM
Rose
Rose - avatar
+ 5
In Python, indentation is a bit tricky, another language like Java would take {} (braces) to show which statements lie within a block. In Python you need to use indentation, and things become tricky, because due to even one small mistake in indentation, you may fall into bad and ugly errors. I suggest, for small codes, you should first write the code without indent, commenting with #{ and #} The opening and closing of a block. After you have written the code, you should start indenting. Hope I helped...
27th Aug 2017, 11:30 AM
Dragon Slayer Xavier
Dragon Slayer Xavier - avatar
+ 5
@Ahri, short and sharp😂😂😂
27th Aug 2017, 11:56 AM
Dragon Slayer Xavier
Dragon Slayer Xavier - avatar