python 复制以及更改列表操作
作者:互联网
- 题目:设置一个老用户列表和一个新用户列表,检查老用户列表中是否与新注册的用户名字有重复(不区分大小写),老用户列表不能被破坏
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")
标签:usernames,更改,python,newusers,用户,been,列表,copy 来源: https://www.cnblogs.com/yhzhao1/p/13334491.html