单选题

班级组织户外活动,老师要统计带水杯的同学名单。已知学生信息列表为:

students = [{"name": "小明", "has_cup": True}, {"name": "小红", "has_cup": False}, {"name": "小刚",

"has_cup": True}],正确的推导式是?( )

A

[student["name"] for student in students if has_cup]

B

[name for student in students where student.has_cup]

C

[student["name"] for student in students if student["has_cup"]]

D

[student.name for student in students when student.has_cup]

赣ICP备20007335号-2