+ 3
Can anyone explain me what indentation mean in python and how to remember it
Hello there developers I have started to learn python this week and as soon I have reached if statement (conditions) in python I have noticed that it's very important to learn and see how indentation really work on python otherwise python will provide a beautiful error
9 ответов
+ 5
Ahh I get what you mean, I used to be in that problem. Don't actually use 4 spaces, use tab, it's technically 4 spaces but in 1 character.
4 spaces -" "
Indentation/Tab -" "
It's very identical but to not get confused, try to delete it, if it takes 2 or more tries to delete it then that means it's not a tab, if it took only 1 try then it's a tab
+ 6
About indentation:
https://code.sololearn.com/cT5BRIbkia21/?ref=app
+ 3
Python indentation is a way of telling a Python interpreter that the group of statements belongs to a particular block of code. A block is a combination of all these statements. Block can be regarded as the grouping of statements for a specific purpose. Most of the programming languages like C, C++, Java use braces { } to define a block of code. Python uses indentation to highlight the blocks of code. Whitespace is used for indentation in Python. All statements with the same distance to the right belong to the same block of code. If a block has to be more deeply nested, it is simply indented further to the right.
+ 2
Indentation means " " or 4 spaces.
an example is
x = 1
if x == 1:
print("True")
else:
print("False")
I can't explain why indentation works but I'm pretty sure it's easy to understand
+ 2
Da GD Bot I know this but how you are going to define that how many spaces we have to use while writting code
+ 2
Frey
The indentation is the tabulation.
+ 1
What do you mean by "How many spaces we have to use while writing code"?
+ 1
Da GD Bot
as Python says use 4 spaces per indentation level.
like in
Python 3 disallows mixing the use of tabs and spaces for indentation.
and Python 2 code indented with a mixture of tabs and spaces should be converted to using spaces exclusively."
so suppose you are writing an if else statement program and you will use one step [tap] for spacings the statement and then back you come up to the else statement can we use 2 steps more space then befor ?
+ 1
I think what you meant by it is when to use it. You should use it every time you use a statement like if statement.