遍歷列表current——usrs,對於其中的每個用戶名都檢查是否被使用,且不區分大小寫。
current_usrs = ['alice','Bob','carolina','admin','eve']
new_usrs = ['Alice','bob','sevischi','bruce','hellman']
for usr in new_usrs:
if usr.lower() in [current_usr.lower() for current_usr in current_usrs] : #關鍵就是要學會使用列表解析
print(usr + " was been used.")
明白了思想,程序都是簡單的。