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
  • 28,235
  • 9
  • 60
  • 81
Zark Bardoo
  • 468
  • 5
  • 15
  • 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