Creating a dictionary from a .txt file
Mark Janssen
dreamingforward at gmail.com
Sun Mar 31 12:20:25 EDT 2013
>
> Every line is now an element in list d. The question I have now is how can
> I make a dictionary out of the list d with the car manufacturer as the key
> and a tuple containing the year and the model should be the key's value.
> Here is a sample of what list d looks like:
>
> ['1899 Horsey Horseless', '1909 Ford Model T', '1911 Overland OctoAuto',
> '2003 Hummer H2', '2004 Chevy SSR']
>
> Any help would be appreciated!
>
>
As long as your data is consistently ordered, just use list indexing. d[2]
is your key, and (d[1],d[3]) the key's value.
Mark
Tacoma, Washington
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130331/18e75453/attachment.html>
More information about the Python-list
mailing list