Created
August 29, 2022 13:11
-
-
Save sebastianschramm/8304e15472ee8bf37a840abefa395460 to your computer and use it in GitHub Desktop.
How to use zip with strict since py3.10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
names = ['a', 'b', 'c'] | |
values = [10, 54, 2] | |
values_too_long = values + [10] | |
""" | |
>>> {k: v for k, v in zip(names, values_too_long, strict=True)} | |
ValueError: zip() argument 2 is longer than argument 1 | |
>>> {k: v for k, v in zip(names, values_too_long, strict=False)} | |
{'a': 10, 'b': 54, 'c': 2} | |
>>> {k: v for k, v in zip(names, values, strict=True)} | |
{'a': 10, 'b': 54, 'c': 2} | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
dependencies: python3.10