September 2026
1051 pages
35h 4m
English
Using conditional statements, which we discussed in detail in Chapter 5, Section 5.1, you can adapt the control flow of your programs—for example, to specific events or data read in whatever way. In Python 3.10, structural pattern matching was introduced. This is another control structure for special types of conditionals, which we’ll take a closer look at in this section.
We’ll start with a small example by imagining that our program should respond to a series of commands—for example, those entered by the user or read from a file. Such behavior can be implemented using the if-elif-else statement, as shown in the following abstract example:
command = "version" # from the user or other ...
Read now
Unlock full access