Search for mapping solution

Markus Joschko jocsch at phreaker.net
Sun Jul 6 15:17:36 EDT 2003


Hi,
stated in a post befor, I'm a java programmer, fascinated about the elegant
way python solves iterations. Maybe you can show me a solution how to map
the following

I have a List:

Name - Number - Costs

lines = [['fred','333','0,10'],['sam','444','1'],['fred','333','0,50']]

Now I want to have it in a dictionary(name,costs)  Should look like
{'fred':'0,60' , 'sam':'1'}

What's an elegant way to do it? I can use a lot of loops, but I assume, that
there is a better way of doing so.

Thanks, 
 Markus




More information about the Python-list mailing list