+ 1
What's the difference between pass and break?
I encounterd some codes where they give unexpected results can some body explain in depth? Thanks in advance! 😁
2 ответов
+ 1
Pass is a placeholder used when you first define your class or function and you want to update it in the future. It is used because empty blocks of code are not allowed in python. Pass does nothing, i think it is equivalent to nop(no operation) in assembly language, just jump to the next instruction.
On the other hand break is used inside a loop( for or while) to stop it when a certain condition is met.
I hope you now see the difference between the two.
0
QTWizard thanks Alot!