other languages, Python notably doesn't exhibit fallthrough behavior. letter = input("Put in a single letter: ").strip()[0].casefold() # first non-whitespace character of the input, lowercase match letter: case 'a' | 'e' | 'i' | 'o' | 'u': # Unlike conditions in if statements, the `or` keyword cannot be used here to differentiate between cases print(f"Letter {letter} is a vowel!") case 'y': print(f"Letter {letter} may be a vowel.) case _: # `case _` is equivalent to `default` from C and others print(f"Letter {letter} is not a vowel!") Exception handling A number of languages implement a form of switch statement in exception handling, where if an exception is raised in a block, a separate branch is chosen, depending on the exception. In some cases a default branch, if no exception is raised, is also present. An early example is Modula-3, which use the TRY...EXCEPT syntax, where each EXCEPT defines a case. This is also found in Delphi, Scala, and Visual Basic .NET. Alternatives Some alternatives to switch statements can be: A series of if-else conditionals that examine the target one value at a time. Fallthrough behavior can be achieved with a sequence of if conditionals each without the else clause. A lookup table, which contains, as keys, the case values and, as values, the part under the case statement. (In some languages, only actual data types are allowed as values in the lookup table. In other languages, it is also possible to assign functions as lookup table values, gaining the same flexibility as a real switch statement. See Control table article for more detail on this). Lua does not support case/switch statements. This lookup technique is one way to implement switch statements in the Lua language, which has no built-in switch. In some cases, lookup tables are more efficient than non-optimized switch statements since many languages can optimize table lookups, whereas switch statements are not optimized unless the range of values is small with few gaps. A non-optimized, non-binary search lookup, however, will almost certainly be slower than either a non-optimized switch or the equivalent multiple if-else statements. A control table (that may be implemented as a simple lookup table) can also be customized to accommodate multiple conditions on multiple inputs if required and usually exhibits greater 'visual compactness' than an equivalent switch (that can occupy many statements). Pattern matching, which is used to implement switch-like functionality in many functional languages. See also