赞
踩
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 not in 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!
#增加一些难度,在列表中存在大小写
favorite_languages = {
'Jen': 'python','sarah':
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。