is no switch or case statement in python that selects an action based on variable' value insteadyou usually code multiway branching as series of if/elif testsas in the prior exampleand occasionally by indexing dictionaries or searching lists because dictionaries and lists can be built at runtime dynamicallythey are sometimes more flexible than hardcoded if logic in your scriptchoice 'hamprint({'spam' dictionary-based 'switch'ham' use has_key or get for default 'eggs' 'bacon' }[choice] although it may take few moments for this to sink in the first time you see itthis dictionary is multiway branch--indexing on the key choice branches to one of set of valuesmuch like switch in an almost equivalent but more verbose python if statement might look like the followingif choice ='spam'print( elif choice ='ham'print( elif choice ='eggs'print( elif choice ='bacon'print( elseprint('bad choice' the equivalent if statement though it' perhaps more readablethe potential downside of an if like this is thatshort of constructing it as string and running it with tools like the prior eval or execyou cannot construct it at runtime as easily as dictionary in more dynamic programsdata structures offer added flexibility handling switch defaults notice the else clause on the if here to handle the default case when no key matches as we saw in dictionary defaults can be coded with in expressionsget method callsor exception catching with the try statement introduced in the preceding all of the same techniques can be used here to code default action in dictionary-based multiway branch as review in the context of this use casehere' the get scheme at work with defaultsbranch {'spam' 'ham' 'eggs' print(branch get('spam''bad choice') if statements