链接: https://pan.baidu.com/s/1SzWqGtyiMUH1lsnrQIiHgg 密码: cwx6
# 6 find same value's key
d1 = dict(a = 12, b = 13, c = 12, d = 15, e = 19)
print(d1)
dk = d1.keys()
dv = list(d1.values())
print(dk, dv)
sdv = set(dv)
print(sdv)
if len(sdv) == len(dv):
print('no repeat values')
else:
print('has repeat valuesl')
ldv = list(sdv)
print(ldv)
rep = list()
for x in ldv:
if list(dv).count(x) > 1:
#print(x)
rep.append(x)
print('rep', rep)
for x in rep:
for y in d1:
if d1[y] == x:
print(x, y)
print('dv', dv)
print('ldv', ldv)
for x in dv:
if x in ldv and dv.count(x) > 1:
dv.remove(x)
print('left', set(dv))
dv = list(d1.values())
print('dv', dv)
i = 0
while i < len(dv):
if dv.count(dv[i]) == 1:
dv.remove(dv[i])
i -= 1
i += 1
print('1 dv', dv)
print(set(dv))