编程语言
首页 > 编程语言> > python 复制以及更改列表操作

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