[试图制作一个总是从列表中的列表(至少从顶层列表)中找到两者的程序。这就是我到目前为止所拥有的。
List_Test = [[2]]
if 2 in List_Test:
print("Found!")
elif 2 in List_Test[0][0]:
print("Found in an inner list!")
elif 2 not in List_Test:
print("Not Found.")
我一直想出一个
TypeError of : argument of type 'int' is not iterable
我在做什么错?
List_Test = [[2]]
if 2 in List_Test:
print("Found!")
elif 2 in List_Test[0]:
print("Found in an inner list!")
else:
print("Not Found.")
尝试上面的代码。
[[Note:elif 2 not in List_Test
是多余的,不是必需的。