Quote:
Originally Posted by PeterT
Could you also use a switch statement, rather than lots of elif statements?
|
Yes. Good point. Switch is effectively a series of "if pattern matches value then result".
One difference is that the chain of elifs stops on a match while a switch evaluates all the pairs then picks the first that matches. The switch is slower if there are matches. In most contexts that probably doesn't matter.