From: jwtozer at my-dejanews.com (jwtozer at my-dejanews.com)
Date: Fri, 16 Apr 1999 12:12:55 GMT
Subject: Novice Question: two lists -> dictionary
References: <7f3j1v$f6j$1@nnrp1.dejanews.com> <etdd815x3s7.fsf@m2-225-12.mit.edu>
Message-ID: <7f79g1$kac$1@nnrp1.dejanews.com>
X-UID: 1358                                                  

Thanks to Blake Winton, Quinn Dunkan, frederic pinel, and Alex for your
timely and useful help.  What my associates Visual Basic/Access application
produced in hours, my little Python script produces in seconds.

Jeff




In article <etdd815x3s7.fsf at m2-225-12.mit.edu>,
  Alex <alex at somewhere.round.here> wrote:
>
> You could do something like
>
> **************************************************
> ListA = ['10', '10', '20', '20', '20', '24']
> ListB = ['23', '44', '11', '19', '57', '3']
>
> Dict = {}
> for (key, value) in map (None, ListA, ListB):
>     Dict [key] = Dict.get (key, [])
>     Dict [key].append (value)
>
> print Dict
> **************************************************
>
> The result is
>
> {'24': ['3'], '10': ['23', '44'], '20': ['11', '19', '57']}
>
> See you.
> Alex.
>

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




