【发布时间】:2018-04-29 07:24:42
【问题描述】:
for x in no_dupes: #looks at tuple in list
if x != totallist[x]: #checks when a tuple in no_dupes is not in totallist
return "The graph violates the STC" #ends the function, because as soon as one tuple in no_dupes isn't in totallist, the graph violats the STC.
我想将一个列表(在列表 no_dupes 中)的所有元组与另一个列表(totallist)进行比较,以查看 no_dupes 中的列表的元组是否在 totallist 中不。
这就是 no_dupes 的样子
这就是totallist的样子
错误的样子
如何解决这个错误?
【问题讨论】:
-
欢迎来到 StackOverflow。请阅读并遵循帮助文档中的发布指南。 Minimal, complete, verifiable example 适用于此。在您发布 MCVE 代码并准确描述问题之前,我们无法有效地帮助您。我们应该能够将您发布的代码粘贴到文本文件中并重现您描述的问题。
-
您不能用元组索引列表中的项目。元组可以用作字典键。你试过
x in totallist吗?
标签: python list tuples typeerror networkx