1

I ran the following in the python3 interpreter:

>>> d = dict( a=1, b=2 )
>>> [v for k,*v in d.items()]
[[1], [2]]

Why does using the star operator in this context cause each value to get wrapped in a list?

wjandrea
  • 23,210
  • 7
  • 49
  • 68
Zark Bardoo
  • 416
  • 3
  • 11
  • I failed to visually parse this correctly. The individual `int`s aren't magically getting wrapped in a `list`. Each key-value pair in `d.items()` is itself a sequence that is assigned to `k,*v` (e.g. `k,*v = 'a', 1`). – Zark Bardoo Mar 28 '22 at 17:14

0 Answers0