of wasthat is what is returned if turns out to be truethen the truth or falsity of the whole expression turns on the result of simply returning guarantees that if is truethe whole result is trueand if is falsethe whole result is false similar reasoning can be used to show that the description of or is faithful to the logical definition of or given in the truth table these operational definitions show that python' boolean operators are short-circuit operators that means that true or false value is returned as soon as the result is known in an and where the first expression is false and in an or where the first expression is truepython will not even evaluate the second expression now let' take look at our infinite loop problemresponse[ ="yor "ytreated as boolean expressionthis will always evaluate to true the first thing to notice is that the boolean operator is combining two expressionsthe first is simple conditionand the second is string here is an equivalent parenthesized version(response[ =" "or (" ")by the operational description of orthis expression returns either true (returned by =when response[ is " "or " (when response[ is not " "either of these results is interpreted by python as true more logic-oriented way to think about this is to simply look at the second expression it is nonempty stringso python will always interpret it as true since at least one of the two expressions is always truethe or of the expressions must always be true as well sothe strange behavior of this example is due to some quirks in the definitions of the boolean operators this is one of the few places where the design of python has potential pitfall for the beginning programmer you may wonder about the wisdom of this designyet the flexibility of python allows for certain succinct programming idioms that many programmers find useful let' look at an example frequentlyprograms prompt users for information but offer default value for the response the default valuesometimes listed in square bracketsis used if the user simply hits the key here is an example code fragmentans input("what flavor do you want [vanilla]"if ans !""flavor ans elseflavor "vanillaexploiting the fact that the string in ans can be treated as booleanthe condition in this code can be simplified as followsans input("what flavor do you want [vanilla]"if ansflavor ans elseflavor "vanilla