Python – Convert a Dictionary to a List

We can easily create a Python list by pulling only the values out of a dictionary. This is done via the values() method.


>>> x = {'a':1, 'b':2}
>>> x
{'a': 1, 'b': 2}
>>> y = list(x.values())
>>> y
[(1), (2)



  • Thanks for the tip.

  • vivek

    Thanks a lot . 

  • Quest for Liberty

    I’ve just spent an eon looking for this, thanks very much!

  • gopal

    x = {‘a’:1, ‘b’:2}

    x = [x]