Solved

Create a dictionary from a list in python

Posted on 2015-02-09
3
213 Views
Last Modified: 2015-02-09
I have a list:
['a','b','c']

Open in new window


I would like to turn it into a dictionary that looks like this:
{
	'a':None,
	'b':None,
	'c':none
}

Open in new window


I think this can be accomplished with map(), but not seeing how to do it.
0
Comment
Question by:DrDamnit
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 52

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 40598024
Hi,

pls try

a =['a','b','c']

Res = dict((k,None) for k in a)

Print Res

Regards
0
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 40598040
listA = ['a','b','c']
dictB = {}
for a in listA:
  dictB[a] =None

dictB
0
 
LVL 32

Author Comment

by:DrDamnit
ID: 40598589
0

Featured Post

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
Part One of the two-part Q&A series with MalwareTech.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question