What I am trying to do is delete the key value pairs out of a dictionary if the value is = 0. I seem not to be acheiving that so far.
Python 2.7.5+ (default, Sep 19 2013, 13:48:49)
[GCC 4.8.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> a = [10, 0, 35, 45, 34, 0, 22, 0]
>>> keys = ['One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight']
>>> dictionary = dict(zip(keys, a))
>>> dictionary
{'Seven': 22, 'Six': 0, 'Three': 35, 'Two': 0, 'Four': 45, 'Five': 34, 'Eight': 0, 'One': 10}
>>> {i:dictionary[i] for i in dictionary if i!=0}
{'Seven': 22, 'Six': 0, 'Three': 35, 'Two': 0, 'Four': 45, 'Five': 34, 'Eight': 0, 'One': 10}
>>> del dictionary[key] if val=0
File "<stdin>", line 1
del dictionary[key] if val=0
^
SyntaxError: invalid syntax
>>> if x in dictionary = 0 del dictionary[key]
File "<stdin>", line 1
if x in dictionary = 0 del dictionary[key]
^
SyntaxError: invalid syntax
>>> if x in dictionary == 0 del dictionary[key]
File "<stdin>", line 1
if x in dictionary == 0 del dictionary[key]
^
SyntaxError: invalid syntax
>>>
How should I be attacking this?