Chalarangelo / 30-seconds-of-python

Short Python code snippets for all your development needs
https://www.30secondsofcode.org/python/p/1
Creative Commons Attribution 4.0 International
8.83k stars 1.26k forks source link

[FEATURE] Using dict for to_dictionary #203

Closed geekypandey closed 4 years ago

geekypandey commented 4 years ago

I totally understand their are preferences in the different choices between the different Python offering, so just suggesting one here for to_dictionary. Would love to hear your thoughts on it.

We could direct make use of the dict constructor which would make dictionary.

Current implementation

def to_dictionary(keys, values):
    return {key:value for key, value in zip(keys, values)}

Suggested implementation

def to_dictionary(key, values):
    return dict(zip(key, values))