Last active
August 21, 2022 11:32
-
-
Save sebastianschramm/9279aa9b929ece84b2aabde89ca13284 to your computer and use it in GitHub Desktop.
How to initialize a dictionary from a list of keys?
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
feature_names = ["sepal_length", "sepal_width", "petal_length", "petal_width"] | |
default_type = float | |
feature_map = dict.fromkeys(feature_names, default_type) | |
""" | |
>>> feature_map | |
{'sepal_length': <class 'float'>, 'sepal_width': <class 'float'>, | |
'petal_length': <class 'float'>, 'petal_width': <class 'float'>} | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
dependencies: python3.9