题解 | #禁止重复注册#
禁止重复注册
https://www.nowcoder.com/practice/43acd439112c4b85a9168ad3dd7e2bd1
current_users=['Niuniu','Niumei','GURR','LOLO'] current_users_up=[i.upper() for i in current_users] #将各元素先统一大写,复制给一临时列表 new_users=['GurR','Niu Ke Le','LoLo','Tuo Rui Chi'] for i in range(len(new_users)): if new_users[i].upper() in current_users_up: print(f'The user name {new_users[i]} has already been registered! Please change it and try again!') else: print(f'Congratulations, the user name {new_users[i]} is available!')