题解 | 禁止重复注册

禁止重复注册

https://www.nowcoder.com/practice/43acd439112c4b85a9168ad3dd7e2bd1

current_users=["Niuniu","Niumei","GURR","LOLO"]
new_users=["GurR","Niu Ke Le","LoLo","Tuo Rui Chi"]
current_users_lower = [user.lower() for user in current_users]
# 遍历新用户列表,逐个检查用户名是否已注册
for user in new_users:
    # 将当前遍历的新用户名转为小写
    user_lower = user.lower()
    if user_lower in current_users_lower:
        # 用户名已存在,输出提示
        print(f'The user name {user} has already been registered! Please change it and try again!')
    else:
        # 用户名可用,输出提示
        print(f'Congratulations, the user name {user} is available!')

全部评论

相关推荐

03-10 11:23
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
1
分享

创作者周榜

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