Python - Python Indenting Code
Python में Code indentation को काफी महत्व दिया गया है | Python में Code Indentation का इस्तेमाल functions, classes, Loops और control statements के लिए किया जाता है |
Python में curly braces({}) की जगह code indentation का इस्तेमाल किया जाता है |
Python में जब code indentation में colon(:) या delimiter दिया जाता है तब automatically अगले line पर interpreter द्वारा tab( ) दिया जाता है |
Function
Source Code :Output :def func(): a = 5 print(a) func()
5
For Loop
Source Code :Output :list = [1, 5, 8, 9] for i in list: print(i)
1 5 8 9
Class
Source Code :Output :class myClass: def func(): a = 5 print(a) myClass.func()
5