擅长:python、mysql、java
<p>因为您希望结果是一个列表列表,所以应该尝试<code>[[item for item in sublist if (condition)] for sublist in biglist]</code>形式的命令。试试这个:</p>
<pre><code>A = [['Computer Science', 'Gender- Male', 'Race Ethnicity- Hispanic', 'Race Ethnicity- White'],
['Computer Science', 'Gender- Female', 'Race Ethnicity- White'],
['History', 'Gender-Female', 'Race Ethnicity- Black'],
['Mechanical Engineering', 'Geder- Male', 'Race Ethnicity- American Indian or Alaskan Native', 'Race Ethnicity- Hispanic']]
print([ [info for info in student if "Race Ethnicity" in info] for student in A ])
</code></pre>