Not using explicit unpacking¶
When you see multiple variables being defined followed by an assignment to a list (e.g.
elem0, elem1, elem2 = elems, where
elem2 are variables and
elems is a list), Python will automatically iterate through the list and assign
elem1, and so on.
The code below manually creates multiple variables to access the items in a list. This code is error-prone and unnecessarily verbose, as well as tedious to write.
elems = [4, 7, 18] elem0 = elems elem1 = elems elem2 = elems