第12277题 单选
给定Python学生字典列表,选择正确提取has_cup为True的同学姓名的列表推导式
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]
提交0次 正确率0.00%
答案解析