Dictionary Values to a List


/ Published in: Python
Save to your folder(s)

This shows how to convert values from a dictionary and make them a list.


Copy this code and paste it in your HTML
  1. data = {'Ken':89, 'John': 92, 'Sue':95, 'Karen':78} #Sets up our Dictionary
  2.  
  3. your_list = list(data.values())
  4. # (don't use 'list' as the variable name
  5. # since it's already a standard function)
  6.  
  7. print(your_list)
  8. # [89, 92, 95, 78]

URL: http://stackoverflow.com/questions/38319568/how-do-i-make-a-list-out-of-data-derived-from-a-dictionary/38319779#38319779

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.