单选题 适中
#16728

执行以下Python代码后,输出的结果是?() words = [ "hello " , "world " , "python" ] result = [ ch…

执行以下Python代码后,输出的结果是?()

words = ["hello ", "world ", "python"]
result = [char for word in words for char in word if char in 'aeiou '] 
print(len(result))
未登录也能判分,登录后才会记录
答案与解析
正确答案:B
解析
首先遍历words列表中的每个字符串元素。对每个字符串,再逐个遍历其字符。在内层遍历中,判断当前字符是否属于集合'aeiou '(即元音字母和空格)。若条件成立,则将该字符加入生成的列表result中。最终result包含所有满足条件的字符。len(result)计算该列表中元素的总数。