- 题目:设置一个老用户列表和一个新用户列表,检查老用户列表中是否与新注册的用户名字有重复(不区分大小写),老用户列表不能被破坏
usernames = ['admin','Tom','john','jack','philip']
usernames_copy = usernames[:] #复制列表操作
for i in range(0,len(usernames_copy)): #更改列表操作
usernames_copy[i] = usernames_copy[i].lower()
newusers = ['A','B','C','D','tom']
for newuser in newusers:
if newuser.lower() in usernames_copy:
print('This username has been used')
else:
print("This username hasn't been used")