Python – Convert a Dictionary to a List

Code — Tags: — Mark @ 9:53 pm

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)

  • http://convert-wma-to-mp3.biz/convert-protected-wma.html Rocchi

    Thanks for the tip.

  • vivek

    Thanks a lot . 

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
(c) 2014 Mark Stahler – Blog | powered by WordPress with Barecity