Please pardon me if it looks to be a duplicate. I have used the methods as provided at link 1 and link 2
Python version I am using 2.7.3. I am passing a dictionary into a function and Want to remove keys if a condition is true.
When I check the length before and after passing dictionary are same.
My code is:
def checkDomain(**dictArgum):
for key in dictArgum.keys():
inn=0
out=0
hel=0
pred=dictArgum[key]
#iterate over the value i.e pred.. increase inn, out and hel values
if inn!=3 or out!=3 or hel!=6:
dictArgum.pop(key, None)# this tried
del dictArgum[key] ###This also doesn't remove the keys
print "The old length is ", len(predictDict) #it prints 86
checkDomain(**predictDict) #pass my dictionary
print "Now the length is ", len(predictDict) #this also prints 86
Also, I request you to help me understand how to reply to the replies. Every time I fail to reply properly. The line breaks or writing code doesn't work with me. Thank you.