题解 | #禁止重复注册#
禁止重复注册
http://www.nowcoder.com/practice/43acd439112c4b85a9168ad3dd7e2bd1
current_users = ['Niuniu','Niumei','GURR','LOLO'] #将当前用户组用户名全部小写,方便比较 current_users = [user.lower() for user in current_users]
#新用户组 new_users = ['GurR','Niu Ke Le','LoLo','Tuo Rui Chi']
#遍历新用户组 for i in new_users: #如果新用户小写后发现存在于当前用户组中 if i.lower() in current_users: print(f'The user name {i} has already been registered! Please change it and try again!') else: print(f'Congratulations, the user name {i} is available!')