# Given a dictionary that contains a number of employee information (name and gender male is 0, 1 female), writing programs for employees of the male gender delete information
dic = { 'Bob': 0, 'red': 1, 'small Huang ': 0,' Zhang ': 0,' Xiaohua ': 0,' Betty ':. 1}
Print ( "dictionary before deleting:% S"% DIC)
Keys = []
values = []
for ( Key, value) in dic.items ():
keys.append (Key)
values.append (value)
for value in values:
IF value == 0:
index = values.index (value)
DelKey Keys = [index]
del DIC [DelKey]
values [index] = "placeholder for"
Keys [index] = "placeholder for"
Print ( "dictionary after deletion:% s"% dic)
Python: 06 write delete gender male employee information 0 (dictionary)
Guess you like
Origin blog.csdn.net/weixin_44015669/article/details/104101370
Ranking