You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

27 lines
780 B

From: jwtozer at my-dejanews.com (jwtozer at my-dejanews.com)
Date: Thu, 15 Apr 1999 02:31:27 GMT
Subject: Novice Question: two lists -> dictionary
Message-ID: <7f3j1v$f6j$1@nnrp1.dejanews.com>
X-UID: 381
How do I make the members of one list the key of a dictionary and the members
of a second list the members of list values associated with with those keys?
Given:
ListA = ['10', '10', '20', '20', '20', '24']
ListB = ['23', '44', '11', '19', '57', '3']
Desired Result:
Dict = {'10': ['23','44'],'20': ['11','19','57'], '24': ['3']}
Any help will be much appreciated.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own