python 用户注册用户名
实现用户注册网站,编辑用户名时判断是否已经存在:
若存在则提示“The name you used have already existed,please change your name”
若不存在,则提示“register success!”,并将其加入用户列表。
最后打印出用户列表
PS:不区分大小写
usrs = ['root','administrator','admin','ming','hong','guo'] new_usr = input('Please input your name:') if new_usr.lower() in usrs: print('The name you used have already existed,please change your name.') else: usrs.append(new_usr.lower()) print('register success!') print(usrs)