我写了一个简单的脚本,其范围是:
list=[1,19,46,28 etc...]
dictionary={Joey:(10,2,6,19), Emily: (0,3), etc}
Run Code Online (Sandbox Code Playgroud)
现在我需要找到字典中所有值中至少有一个列表条目的键
示例:19是Joeys值,因此Joey是赢家.
我是怎么做到的(根本没有程序员)
# NodesOfSet = the list
# elementsAndTheirNodes = the dictionary
# loop as many times as the number of key:value entries in the dictionary element:nodes
# simply: loop over all the elements
for i in range (0, len (elementsAndTheirNodes.keys())):
# there is an indent here (otherwise it wouldnt work anyway)
# loop over the tuple that serves as the value for each key for a given i-th key:value
# simply: …Run Code Online (Sandbox Code Playgroud) 我有一个列表,其中包含多达数千个条目及其值:
lst = [
[entry1, [value1, value2, value3]],
[entry2, [value4, value5, value6, value7]],
...
]
Run Code Online (Sandbox Code Playgroud)
需要从每个条目的值中弹出除最大值之外的所有内容.
你知道这样做的顺利方式吗?谢谢!