Ok you got me thinking.  I used the same thing I posted before but 
created a one liner that as a side affect makes adict like before.
[adict.__setitem__(x,adict.get(x,0)+1) for x in l]

I think it's kinda funny and ugly, ohh and not particuarly clear
about 
what it does.

Wolfram Kraus wrote:

> get(key, default) is your friend here:
>       for i in a_list:
>           items_dict[i] = items_dict.get(i, 0) + 1
>
> get() (and his "brother" setdefault()) are mighty
dictionary-methods.
>


                
__________________________________ 
Do you Yahoo!? 
Take Yahoo! Mail with you! Get it on your mobile phone. 
http://mobile.yahoo.com/maildemo 
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to