python - 返回所有出现多次且具有不同值的键?
问题描述
所以我有 :
dictionary = {"John:"Legend","Ariana":"Grande", "Sam":"Smith",Ariana":"Smith","Lewis":"Capaldi","John":"Smith"}
所以在这里我想在列表中返回“Ariana”和“John”,因为它们都多次作为键出现,但每次都有不同的值。
到目前为止,我有:
for key in dictionary:
authors.append(key)
duplicates = []
for key in dictionary:
if key not in duplicates:
duplicates.append(key) # this is to find all the duplicate keys
到目前为止这是正确的吗?我从这里去哪里?
解决方案
推荐阅读
- assembly - 从 NASM 中的非阻塞标准输入读取
- flutter - Flutter在gridview下方添加容器
- python - 在包含其他数据类型的列表中查找最小整数值的索引
- scala - ScalaTest 与 Scalajs:没有测试被执行
- c# - 使用 C# 将 XML 转换为 UTF-8
- azure - 如何在启用了 EF Core 迁移的 Azure 中运行蓝绿色部署
- aframe - 如何将 VRML 的 Geometry ElevationGrid 转换为 Aframe
- cakephp - 我想在我的 CakePHP 插件命名空间前加上我的名字
- vue.js - vuejs:如何在相同组件中传递共享道具?
- java - TypeError: 'JavaPackage' object is not callable (spark._jvm)