0
Help out with if statement
I don't seem to understand anything in If statement especially the indentation. Can someone explain to me in simplest form by siting examples that I will understand easily. Please, explain indentation in simplest form for me backing it with examples.
8 Respostas
+ 2
Yinka Bello I think this may help you to understand the concept of indentation in python.
It's very very very important.
https://code.sololearn.com/cPbFqB2JOP4m/?ref=app
+ 1
Which language?
I suppose it's Python
+ 1
Yes. I am talking about python. Pls use simplest example for the indentation sir. Bless ur heart
+ 1
Stefan , thanks so much. I learnt indentation simply means space or tabs. please, what am I suppose to space and how many spaces should one live behind? Please explain indentation in a very simple way backing it with few examples so that I can run it and see the results
+ 1
Yinka Bello you can decide how the length of the tabs/spaces can be. But they all may match to an indentation level and as said what you want to express
Indentation means first "space" but in python they are very important, these spaces.
We use them with:
*If statements
*For statements
*While statements
*Try ... except statements
*...
There are many domains.
Sorry for my English level. Mother tongue: French
0
Yes, my python
0
Assuming Python
Indentation is a way to associate blocks of code to a previous line of code.
Example:
for i in range(6):
print(i) # 0,1,2,3,4,5,
if i%2 ==0:
print(i) # 0,2,4
As you can see, all the indented items belong to the first line, but the different indented levels cause the code to react to the line it is indented from.
Hope this helps
0
Stefan , let me have your watsap number