athletes = [['Phelps', 'Lochte', 'Schooling', 'Ledecky', 'Franklin'], ['Felix', 'Bolt', 'Gardner', 'Eaton'], ['Biles', 'Douglas', 'Hamm', 'Raisman', 'Mikulak', 'Dalton']]
t = []
other = []
for lst in athletes:
for lst2 in athletes:
if 't' in lst2:
t.append(lst2)
else:
other.append(lst2)
Try it online!
输出:
我们可以使用来自^{} 的
partition
配方。你知道吗without_t
和with_t
与be迭代器。如果你想把它们列出来,只需做without_t = list(witout_t)
。你知道吗相关问题 更多 >
编程相关推荐