2016-03-21 14 views
0

Hello guys just encountered an error after running my final code and i was wondering what i have done wrong?なぜTypeError:unhashable型ですか? 'list'が出ていますか?

輸入

再デフパスワード(): プリント( '6文字以上でなければならないパスワード\ n個の\ nパスワードを入力します。\ n')

while True: 
    password = raw_input('Password: ') 
    if 6 < len(password): 
     break 
    print ('The password must be more than 6 characters.\n') 

password_scores = {0:'Very weak', 1:'Weak', 2:'Medium', 3:'Strong', 4:'Very strong'} 
password_strength = dict.fromkeys(['has_upper', 'has_lower', 'has_num' , 'has_sym', False]) 
if re.search(r'[A-Z]', password): 
    password_strength['has_upper'] = True 
if re.search(r'[a-z]', password): 
    password_strength['has_lower'] = True 
if re.search(r'[0-9]', password): 
    password_strength['has_num'] = True 
if re.search(list("[ !#$%&'()*+,-./[\\\]^_`{|}~ ]") , password): 
    password_strength['has_sym'] = True 

score = len([b for b in password_strength.values() if b]) 

print ('Password is %s' % password_scores[score]) 

パスワードを()

答えて

0

は、次のいずれかであなたのif書を交換し、それが動作します:

if re.search("[!#$%&'()*+,-./[\\\]^_`{|}~ ]" , password): 
    password_strength['has_sym'] = True