Skip to content

Files

Latest commit

 

History

History
28 lines (18 loc) · 674 Bytes

unbalanced-tuple-unpacking.md

File metadata and controls

28 lines (18 loc) · 674 Bytes

Pattern: Unbalanced tuple unpacking

Issue: -

Description

Used when there is an unbalanced tuple unpacking in assignment. Sequence unpacking requires the list of variables on the left to have the same number of elements as the length of the sequence.

Example of incorrect code:

def do_stuff():
    first, second = 1, 2, 3 # last tuple value has no matching element
    return first + second

Example of correct code:

def do_stuff():
    first, second = 1, 2
    return first + second

Further Reading