我有列表mainList
列表。我希望在subList
附加這個列表,但只有第2,3,4,5和7項。附加列表與其他列表的某些值
for subList in file:
mainList.append(subList[#items 2,3,4,5,7])
有沒有辦法做到這一點,除了
for subList in file:
temp = []
for item in subList[1:]:
if #item not the 6th item:
temp.append(item)
mainList.append(temp)
我能做到這一點,而不temp
列表和嵌套的for循環追加這個名單?