[Tutor] Unique elements mapping

Srinivas Iyyer srini_iyyer_bio at yahoo.com
Fri Mar 25 18:15:10 CET 2005


Hi all:

I have a question and I request groups help please.

My list has two columns:

Name    State
Drew    Virginia
Noel    Maryland
Niki    Virginia
Adams   Maryland
Jose    Florida
Monica  Virginia
Andrews Maryland


I would like to have my ouput like this:

Virginia :  Drew,Niki,Monica
Maryland:   Noel,Adams, Andrews
Florida:  Jose


Can you help how should I code :


for line in my_list:
        key = line.split('\t')[0]
        val = line.split('\t')[1]
        

dict = dict(zip(key,val))

this was my strategy ... but I could not make it
work.. 
Please help

srini


		
__________________________________ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/ 


More information about the Tutor mailing list