Difference between break and pass in Python

  • What is the difference between break and pass in Python

    The break statement forces the execution to exit the iteration structure (loop) effectively stopping any further execution from that code block. Use break statements when the loop should not be executed anymore
    pass is used as a placeholder. Called a null statement, the pass statement is used to fill out a code block without actually doing anything.
    The main difference between break and continue statement is that when break keyword is encountered, it will exit the loop. Python Pass Statement is used as a placeholder inside loops, functions, class, if-statement that is meant to be implemented later. Python pass is a null statement.
  • python bootcamp 2021
datai analytics