0

Is there a straight forward way to add a list to a dictionary?

For example

a = [1,2,3]
d = dict(a)

I have seen a way (I do not remember exactly how) that add a list to a dictionary making the name of the list as key and list's values as values in the dictionary, something like this:

a = [1,2,3]
d = somefunction(a)
print(d)

Output:

{'a':[1,2,3]}
martineau
  • 119,623
  • 25
  • 170
  • 301
Dante
  • 1

0 Answers0