with test for an empty after the loop ( if not :although that' true in this examplethe else provides explicit syntax for this coding pattern (it' more obviously search-failure clause here)and such an explicit empty test may not apply in some cases the loop else becomes even more useful when used in conjunction with the for loop--the topic of the next section--because sequence iteration is not under your control why you will careemulating while loops the section on expression statements in stated that python doesn' allow statements such as assignments to appear in places where it expects an expression that iseach statement must generally appear on line by itselfnot nested in larger construct that means this common language coding pattern won' work in pythonwhile (( next(obj)!nullprocess assignments return the value assignedbut python assignments are just statementsnot expressions this eliminates notorious class of errorsyou can' accidentally type in python when you mean =if you need similar behaviorthoughthere are at least three ways to get the same effect in python while loops without embedding assignments in loop tests you can move the assignment into the loop body with breakwhile truex next(objif not xbreak process or move the assignment into the loop with testsx true while xx next(objif xprocess or move the first assignment outside the loopx next(objwhile xprocess next(objof these three coding patternsthe first may be considered by some to be the least structuredbut it also seems to be the simplest and is the most commonly used simple python for loop may replace such loops as well and be more pythonicbut doesn' have directly analogous toolfor in objprocess while and for loops