题解 | #禁止重复注册#

禁止重复注册

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)

全部评论

相关推荐

27双非本,最近面试被挂麻了面试官说简历内容太简单了,技术栈要单独一行,各位佬有啥建议吗
LZStarV:项目太简单了,你像用什么开发的技术栈没必要写一句话,按点写就好了;有特色的比如说WebSocket、视频流这种狠狠吹,那就好看多了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务