班级组织户外活动,老师要统计带水杯的同学名单。已知学生信息列表为:
students = [{"name": "小明", "has_cup": True}, {"name": "小红", "has_cup": False}, {"name": "小刚",
"has_cup": True}],正确的推导式是?( )
[student["name"] for student in students if has_cup]
[name for student in students where student.has_cup]
[student["name"] for student in students if student["has_cup"]]
[student.name for student in students when student.has_cup]