How to use the pass statement?

前端 未结 15 2501
旧时难觅i
旧时难觅i 2020-11-22 15:03

I am in the process of learning Python and I have reached the section about the pass statement. The guide I\'m using defines it as being a Null sta

15条回答
  •  轮回少年
    2020-11-22 15:17

    Pass refers to ignore....as simple as it is ....if the given condition is true and the next statement is pass it ignores that value or iteration and proceed to the next line ..... Example

    For i in range (1,100):
        If i%2==0:
                      Pass 
        Else:
                      Print(i)
    

    Output: Prints all the odd numbers from 1-100

    This is because modulus of even number is equal to zero ,hence it ignores the number and proceeds to next number ,since odd numbers modulus is not equal to zero the Else part of the loop is executed and its printed

提交回复
热议问题