5_10 检查用户名
1 """ 2 新8班的学生是否在我原来的12班 3 """ 4 users_1_12 = ['admin','zhen yuhan','zhang dazhi','gao lanlan','guo xujie', 5 'cheng jiaqi','li yilin','XU JIAYI'] 6 users_2_8 = ['zhen yuhan','xu jiayi','zhang dazhi','li wei','wang yuxuan','liu chenxi', 7 'wang yiwei','cui jialin','wang tong',] 8 users_1_12_class = [] 9 for user12 in users_1_12: 10 users_1_12_class.append(user12.lower()) 11 for user in users_2_8: 12 if user.lower() in users_1_12_class: 13 print(f"Hello {user.title()},my 12's student.") 14 else: 15 print(f"Hello {user.title()},my new student.")
12班列表需要被遍历,然后将其中的元素的小写添加进新的列表
再进行比较