Skip to content

Commit 0d646ff

Browse files
authored
Update indentation.md
1 parent 0edfcf9 commit 0d646ff

1 file changed

Lines changed: 39 additions & 13 deletions

File tree

Basic/indentation.md

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
## Indentation :wrench:
1+
## Indentation
22

33

4-
### Basic of Indentation :vhs:
4+
### Basic of Indentation
55
After completion of data type and variable I hope you understand it now I am going to here to present
66
**indentation** concepts which play a vital role in python app development
77

@@ -17,36 +17,62 @@ After completion of data type and variable I hope you understand it now I am goi
1717
consider if loop
1818
In C Programing :scroll::
1919
```python
20-
if(conditions) {
21-
#main code
22-
}
20+
if(conditions) {
21+
#main code
22+
}
2323
```
24-
In python Programing :snake: :
24+
In python Programing:
2525

26+
With Brackets
2627
```python
27-
if(conditions) :
28-
#main code
28+
if(conditions) :
29+
#Write Your Main Code Here
30+
```
31+
32+
without Brackets
33+
```python
34+
if conditions:
35+
#Write Your Main Code Here
2936
```
3037

31-
### How can we write code block :bookmark_tabs: in one line
38+
### How can we write code block in one line
3239
- Indentation can be ignored in line continuation.
3340
- But it's a good idea to always indent. It makes the code more readable :bookmark_tabs:.
3441

3542
Example:
43+
with Brackets
44+
```python
45+
if(conditions) :#main code
46+
```
47+
48+
Without Brackets
3649
```python
37-
if(conditions) :#main code
50+
if conditions :#Write Your Main Code Here
3851
```
3952

4053
### If you give wrong :hotsprings: indentation which error will occured
4154

4255
Consider following code block
4356
```python
44-
if(conditions) :
57+
if(1==1) :
4558
print("First line")
4659
print("second line")
4760
```
4861

49-
Incorrect indentation will result into :no_entry:
62+
Incorrect indentation will result into
63+
```python
64+
IndentationError: unindent does not match any outer indentation level
65+
```
66+
67+
Correct Solution
5068
```python
51-
IndentationError:
69+
if 1==1 :
70+
print("First line")
71+
print("second line")
72+
```
73+
74+
Output
75+
```
76+
First line
77+
second line
5278
```

0 commit comments

Comments
 (0)