浙江省高校计算机等级考试二级Python 程序设计题12——统计缺课学生名单|2023备考

笔记整理自B站UPWLB工作生活两不误的个人空间-WLB工作生活两不误个人主页-哔哩哔哩视频教程​​​​​​Python 程序设计题12_哔哩哔哩_bilibili

程序设计题12

Python代码

代码一

all_student = input().split()

present_student = input().split()

all_student = [name.lower() for name in all_student]
present_student = [name.lower() for name in present_student]

res = []
# 第一种
for name in all_student:
    if name not in present_student:
        res.append(name)

print(' '.join(res))

代码二

all_student = input().split()

present_student = input().split()

# 第二种
all_student = [name.lower() for name in all_student]
present_student = [name.lower() for name in present_student]
res = list(set(all_student) - set(present_student))
print(' '.join(res))

输入样例

张三 李四 王五 赵六 Lily Jack
王五 赵六 jack 张三

输出样例

李四 lily

猜你喜欢

转载自blog.csdn.net/Raider1/article/details/129964535
今日推荐