On Mär 28 2021, Greg Wooledge wrote:

> Python is different:
>
>>>> y = ["a", "b", "c", "d"]
>>>> dict(zip(y[::2], y[1::2]))
> {'a': 'b', 'c': 'd'}
>>>> x = ["a", "b", "c"]
>>>> dict(zip(x[::2], x[1::2]))
> {'a': 'b'}
>
> It seems to discard the last (unmatched) value.

>>> dict(zip_longest(x[::2], x[1::2]))
{'a': 'b', 'c': None}

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

Reply via email to