为什么下面的代码不起作用?
data = [["4","5"],["3","7"]]
search = "4"
for sublist in data:
if sublist[1] == "4":
print ("there"), sublist
break
else:
print("not there")
break
非常抱歉给大家带来的困惑。我试图检查整个列表及其所有子列表,但我不明白这只会检查列表的第二个元素,因为我忘记了 Python 的第一个元素位于第 0 个位置。但是,我将如何检查整个列表?删除“break”和[1]?