loop structures and booleans the first line may look bit strange to you remember that while loop continues as long as the expression in the loop heading evaluates to true since true is always truethis appears to be an infinite loop howeverwhen the value of is non-negativethe break statement executeswhich terminates the loop notice that placed the break on the same line as the if this is legal when the body of the if only contains one statement it' common to see one-line if-break combination used as loop exit even this small example can be improved it would be nice if the program issued warning explaining why the input was invalid in the while version of the post-test loopthis is bit awkward we need to add an if so that the warning is not displayed for valid inputs number - start with an illegal value to get into the loop while number number eval(input("enter positive number")if number print("the number you entered was not positive"do you see how the validity check gets repeated in two placesadding warning to the version using break only requires adding an else to the existing if while truenumber eval(input("enter positive number")if > break exit loop if number is valid elseprint("the number you entered was not positive"loop and half some programmers would solve the warning problem from the previous section using slightly different style while truenumber eval(input("enter positive number")if > break loop exit print("the number you entered was not positive"here the loop exit is actually in the middle of the loop body this is called loop and half some purists frown on exits in the midst of loop like thisbut the pattern can be quite handy the loop and half is an elegant way to avoid the priming read in sentinel loop here is the general pattern of sentinel loop implemented as loop and halfwhile trueget next data item if the item is the sentinelbreak process the item