{"id":862,"date":"2014-12-30T09:50:00","date_gmt":"2014-12-30T09:50:00","guid":{"rendered":"https:\/\/fir3netwp.gmsrrpobkbd.com\/2014\/12\/30\/python-create-a-dictonary-using-list-items-as-keys\/"},"modified":"2021-07-24T15:44:23","modified_gmt":"2021-07-24T15:44:23","slug":"python-create-a-dictonary-using-list-items-as-keys","status":"publish","type":"post","link":"https:\/\/www.fir3net.com\/Programming\/Python\/python-create-a-dictonary-using-list-items-as-keys.html","title":{"rendered":"Python – Create a Dictonary using List Items as Keys"},"content":{"rendered":"
Below shows you how to create a dictionary using keys from list items using list comprehension. From this we can also set a default value.<\/p>\n
>>> keys = ['a','b','c','d']
>>> { x:False for x in keys }
{'a': False, 'c': False, 'b': False, 'd': False}<\/pre>\n","protected":false},"excerpt":{"rendered":"Below shows you how to create a dictionary using keys from list items using list comprehension. From this we can also set a default value. >>> keys = [‘a’,’b’,’c’,’d’]>>> { x:False for x in keys }{‘a’: False, ‘c’: False, ‘b’: False, ‘d’: False}<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"yoast_head":"\n
Python - Create a Dictonary using List Items as Keys - Fir3net<\/title>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\n