我有一个由一定长度的子列表组成的列表,有点像[["a","b","c","d"],["a","b","c","d"],["a","b","c","d","e"]]
. 我想要做的是找到没有特定长度的子列表的索引,然后将该索引打印出来。例如,在示例列表中,最后一个子列表的长度不是四,所以我会打印list 2 does not have correct length
. 这是我到目前为止所拥有的:
for i in newlist:
if len(i) == 4:
print("okay")
elif len(i) != 4:
ind = i[0:] #this isnt finished; this prints out the lists with the not correct length, but not their indecies
print("not okay",ind)
提前致谢!