在python中匹配两个索引号相同的列表
错误在python中匹配两个索引号相同的列表,python,Python,错误 文件“C:\Users\..\Desktop\problem\u solution.py”,第101行,在if(compare(newk1,k1)==True)中: 文件“C:\Users\..\Desktop\problem\u solution.py”,第25行,如果a==b: ValueError:包含多个元素的数组的真值不明确。使用a.any()或a.all() 无需将事情复杂化: File "C:\Users\..\Desktop\problem_solution.py", li
文件“C:\Users\..\Desktop\problem\u solution.py”,第101行,在if(compare(newk1,k1)==True)中:
文件“C:\Users\..\Desktop\problem\u solution.py”,第25行,如果a==b:
ValueError:包含多个元素的数组的真值不明确。使用a.any()或a.all()
无需将事情复杂化:
File "C:\Users\..\Desktop\problem_solution.py", line 101, in <module> if(compare(newk1,k1)==True):
File "C:\Users\..\Desktop\problem_solution.py", line 25, in compare if a == b:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
对于范围(0,len(k1))内的i:
这将解决您的问题。请显示您对范围(0,3)内的i的努力:如果i在newk1中,而i在k1中:如果newk1.index(i)==k1.index(i)://执行stuff@ShreyGupta用你尝试过的内容编辑你的问题,而不是在评论中
File "C:\Users\..\Desktop\problem_solution.py", line 101, in <module> if(compare(newk1,k1)==True):
File "C:\Users\..\Desktop\problem_solution.py", line 25, in compare if a == b:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
if list1 == list2:
print "Equal"
else:
print "Not equal"
if(newk1[i] == k1[i]).all
return True
else:
return False