fast dictionary initialization
Random832
random832 at fastmail.com
Fri Jun 10 17:15:46 EDT 2016
pOn Fri, Jun 10, 2016, at 17:07, maurice wrote:
> Hi. If I have already a list of values, let's call it valuesList and the
> keysList, both same sized lists, what is the easiest/quickest way to
> initialize a dictionary with those keys and list, in terms of number of
> lines perhaps?
>
> example:
> valuesList = [1,2,3]
> keysList = ['1','2','3']
>
> So the dictionary can basically convert string to int:
>
> dictionary = {'1':1, '2':2, '3':3}
dict(zip(keysList, valuesList))
More information about the Python-list
mailing list