The structure to be unpacked here is a tuple with two elements, a nested tuple eventually containing 1
and 2
as the mapping result and the defaultdict.
((1, 2), defaultdict(list))
If you need to unpack it correctly, use parentheses at the target of the assignment to specify the structure produced:
(n, m), r = map(int, [1, 2]), defaultdict(list)
with n
, m
and r
having their correct values.
If you use:
n, m = map(int, [1, 2]), defaultdict(list)
the map
result (the iterator) will never get unpacked and simply get assigned as the value for n
.