题解 | #禁止重复注册#
禁止重复注册
https://www.nowcoder.com/practice/43acd439112c4b85a9168ad3dd7e2bd1
关键点在于用户名不区分大小写,于是把旧表的数据upper()或者lower(),然后新表的元素遍历时用同样形式与之比较
current_users = ['Niuniu', 'Niumei', 'GURR', 'LOLO']
new_users = ['GurR', 'Niu Ke Le', 'LoLo', 'Tuo Rui Chi']
a = [i.upper() for i in current_users]for i in new_users:
if i.upper() in a:
print('The user name %s has already been registered! Please change it and try again!' % i)
else:
print('Congratulations, the user name %s is available!' % i)
查看21道真题和解析