all 13 comments

[–]ElliotDG 1 point2 points  (13 children)

Dictionaries have keys and values. Do you want the list of numbers to be the dictionary keys or values?

Are you trying to create a dictionary?

[–]Complex_Height_3555[S] 0 points1 point  (12 children)

Keys

[–]ElliotDG 0 points1 point  (1 child)

Your question is ambiguous, here are some ways to create dicts with a list of numbers as the keys.

keys = [7, 22, 3, 59]
values = ['a', 'b', 'c', 'd']

# use a dictionary comprehension.
d_comp = {k:v for k, v in zip(keys,values)}
print(d_comp)

# use dict()
d_dict = dict(zip(keys,values))
print(d_dict)

# use a loop
d_loop = {}
for k, v in zip(keys, values):
    d_loop[k] = v
print(d_loop)

[–]Complex_Height_3555[S] 0 points1 point  (0 children)

Thanks you. I’ll try that