On Mon, Feb 25, 2013 at 9:33 PM, Anand Chitipothu <anandol...@gmail.com>wrote:

>
> You can iterate over items:
>
> for key, value in dictionary.items():
>     if value == 1:
>         del dictionary[key]
>

I think in Python 3.*, dict.items() returns iterator. If so it won't work
in Python 3.* . So converting it to list would be a better option.

for key in list(dictionary):
   if dictionary[key] == 1:
       del dictionary[key]



-- 
blog : ragsagar.wordpress.com
mail id : python -c "print '@'.join(['ragsagar','.'.join([x for x in
['gmail','com']])])"
_______________________________________________
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers

Reply via email to