current_users =['Tom','Davie','Ted','lina','ice']
new_users =['AM','DK','PA','tom','ted']#一行代码创建新列表,并转换成小写
lower_current_users =[item.lower()for item in current_users]
lower_new_users =[item.lower()for item in new_users
#不区分大小写判断for lower_new_user in lower_new_users:if lower_new_user in lower_current_users:print("the '%s' was been already account!"% lower_new_user)elif lower_new_user notin lower_current_users:print("you can use the id by '%s'"% lower_new_user)
输出显示:
you can use the id by 'am'
you can use the id by 'dk'
you can use the id by 'pa'
the 'tom' was been already account!
the 'ted' was been already account!