flâneur — a map of the web's best reading

Chapter 4 — Computational Thinking and Problem Solving

profsmith89.github.io · saved by 1 readers

Python allows you to assign multiple values to multiple names in one assignment-statement. Here are the semantics: The lefthand side of the assignment operator must be a comma-separated list of names. The righthand side of the assignment operator can be a comma-separated values, or a value that adheres to the sequence abstraction. The first value on the left is given the first name on the right; the second on the left is given the second on the right; and so forth. For the operation to complete without an error, the comma-separated lists on both sides of the assignment operator must have the same number of elements. Similarly, the length of the sequence value on the right must be the same as the number of comma-separated names on the left. This is not an operation you’d want to do all the time, since it can quickly become confusing to lump different things together in a single assignment statement. There are, however, two cases where this functionality is very helpful: Step 1. Write an

Python allows you to assign multiple values to multiple names in one assignment-statement. Here are the semantics: The lefthand side of the assignment operator must be a comma-separated list of names. The righthand side of the assignment operator can be a comma-separated values, or a value that adheres to the sequence abstraction. The first value on the left is given the first name on the right; the second on the left is given the second on the right; and so forth. For the operation to complete without an error, the comma-separated lists on both sides of the assignment operator must have the s

Explore this link on the map →