Building python dict out of a single list -


i have list of items has length of 14:

html_doc = [u'crabtree conservation area - number 28', u'conservation area', u'environment agency flood risk zone 3', u'flood risk zone 3', u'environment agency flood risk zone 2', u'flood risk zone 2', u'buildings structures , works exceeding 90 metres', u'aerodrome safeguarding london heathrow 1', u'controlled parking zone t', u'controlled parking zone t', u'flood zone 3 low residual risk', u'flood zone 3 low residual risk', u"embankment residents' association", u"embankment residents' assoc."] 

each of elements in array should paired "name":"constraint_type" meaning first , second element of list related.

i have code don' think work:

for in xrange(len(html_doc)):   dict.append("name:" html_doc[i], "constraint_type": html_doc[i+1]) 

any idea on this?

html_dict = dict(zip(html_doc[::2], html_doc[1::2])) 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -