Thread
:
Anyone know how to code Python?
View Single Post
12-06-2012, 12:25 PM
#
3
BlackEleven
Redundant Minister of Redundancy
Join Date: Apr 2004
Location: Montreal
Exp:
And a tip to get you a little further: you'll want to turn that list into a dictionary to answer those questions you posted. I'll spoiler it in case you want to figure it out on your own.
Spoiler!
The easiest way is to use zip and slicing. Slicing allows you to specify ranges or portions or a list (in this case every even and every odd element) and zip will transform the two lists into list of tuples (ie paris), which you can then use to make a dictionary ( first element in the tuple becomes the key, the second becomes the item).
Something like this:
communityDict = dict( zip( words[::2], words[1::2] ) )
Last edited by BlackEleven; 12-06-2012 at
12:33 PM
.
The Following User Says Thank You to BlackEleven For This Useful Post:
mykalberta
BlackEleven
View Public Profile
Send a private message to BlackEleven
Find More Posts by BlackEleven