Files
python/reference/concepts/tuple_unpacking.md

7 lines
594 B
Markdown
Raw Permalink Normal View History

# Tuple unpacking
TODO: ADD MORE
- the values in an iterable can be unpacked into variables and used, i.e. `for a, b in zip(s1, s2)` [hamming](../exercise-concepts/hamming.md)
- iterating through a list of tuples, i.e. [(1, 2), (2,3)], each piece of each tuple can be unpacked into a separate variable (syntax: `a, b = (1, 2)`); this works for any sort of iterable (lists, for example, and even strings!) but is commonly used with tuples because they are typically of a known size/length, and so can be safely unpacked into N variables, with names. [hamming](../exercise-concepts/hamming.md)