Solved

Create a dictionary from a list in python

Posted on 2015-02-09
3
139 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
3 Comments
 
LVL 48

Accepted Solution

by:
Rgonzo1971 earned 500 total points
Comment Utility
Hi,

pls try

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

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

Print Res

Regards
0
 
LVL 37

Expert Comment

by:Gerwin Jansen
Comment Utility
listA = ['a','b','c']
dictB = {}
for a in listA:
  dictB[a] =None

dictB
0
 
LVL 32

Author Comment

by:DrDamnit
Comment Utility
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

728 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now