+ 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! 😁

19th Oct 2020, 12:46 AM
VINIT SHARMA
VINIT SHARMA - avatar
2 Réponses
+ 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.
19th Oct 2020, 11:13 AM
QTWizard
0
QTWizard thanks Alot!
21st Oct 2020, 11:58 PM
VINIT SHARMA
VINIT SHARMA - avatar