For the Python language, if you don't use loops when writing code, try not to use loops. Some functions built into the language tend to be more efficient.
Let's take an example to illustrate: For example, we have two lists of the same size, and we need to judge the corresponding elements of the two lists at the same time, and delete the ones that meet the requirements.
x
,y
are two lists, the above example will deletex
they
corresponding elements.- The inner ones
zip
will pack, and the outer onesx
will unpack the processed elements. Note: External function unpacking requires adding numbers to variables.y
zip
zip
*
- Notice that the processed data becomes a tuple.
Is it very simple, there is no loop, but the data is traversed.