+ 2

How do we know if a statement is nested into another statement in python??

2nd Apr 2020, 11:38 AM
Nomita Patwal
Nomita Patwal - avatar
4 Antworten
+ 3
Thanks a lot
2nd Apr 2020, 11:56 AM
Nomita Patwal
Nomita Patwal - avatar
+ 4
I think that you must study about the indentation gap . It works in many of the programing languages along with python.
2nd Apr 2020, 3:26 PM
Ayush Kumar
Ayush Kumar - avatar
+ 3
By indentation. As in: if 1<2: if 6==6: print('program ends') indent is a small gap as you can see in line 2 where a small gap is left behind (if) which shows that it is nested.
2nd Apr 2020, 11:43 AM
Tricker
+ 2
By checking the length of space. if: if: for: while: Like that, it's nested.
2nd Apr 2020, 11:44 AM
你知道規則,我也是
你知道規則,我也是 - avatar