[BangPypers] Python dictionaries, deleting elements while iterating.

ragsagar ragsagar at gmail.com
Mon Feb 25 17:55:20 CET 2013


On Mon, Feb 25, 2013 at 10:15 PM, Anand Chitipothu <anandology at gmail.com>wrote:

>
>
> I think, the second solution I suggested is more Pythonic than using a for
> loop. In Python 3, it can be written as a dictionary-comprehension.
>
> dictionary = {(k, v) for k, v in dictionary.items() if v != 1}
>
>
True. Using dictionary comprehension is the apt solution. I was just
talking about the first solution you suggested.


-- 
blog : ragsagar.wordpress.com
mail id : python -c "print '@'.join(['ragsagar','.'.join([x for x in
['gmail','com']])])"


More information about the BangPypers mailing list