bad choice an in membership test in an if statement can have the same default effectchoice 'baconif choice in branchprint(branch[choice]elseprint('bad choice'bad choice and the try statement is general way to handle defaults by catching and handling the exceptions they' otherwise trigger (for more on exceptionssee ' overview and part vii' full treatment)tryprint(branch[choice]except keyerrorprint('bad choice'bad choice handling larger actions dictionaries are good for associating values with keysbut what about the more complicated actions you can code in the statement blocks associated with if statementsin part ivyou'll learn that dictionaries can also contain functions to represent more complex branch actions and implement general jump tables such functions appear as dictionary valuesthey may be coded as function names or inline lambdasand they are called by adding parentheses to trigger their actions here' an abstract samplerbut stay tuned for rehash of this topic in after we've learned more about function definitiondef function()def default()branch {'spam'lambda'ham'function'eggs'lambdaa table of callable function objects branch get(choicedefault)(although dictionary-based multiway branching is useful in programs that deal with more dynamic datamost programmers will probably find that coding an if statement is the most straightforward way to perform multiway branching as rule of thumb in codingwhen in doubterr on the side of simplicity and readabilityit' the "pythonicway if tests and syntax rules