试图检查满足这些条件的字符串

Eri*_*Lan 1 python if-statement

尝试使用以下代码检查字符串:

def check_password(x):
  if has_unique_letters(x) == False:
    print "Warning! Please ensure letters are not repeated."
  if has_even_vowels(x) == False:
    print "Warning! Please ensure password contains an even number of vowels."
  if has_special_character(x) == False:
    print "Warning! Please ensure password contains at least one of {@, #, *, $}"
  if has_divisible_numbers(x) == False:
    print "Warning! Please ensure all numbers are divisible by 2 or 3."
  print "Sorry, your password does not meet our criteria."
print "Congratulations, your password meets our criteria."

x = raw_input("Please set your password:")
check_password(x)
Run Code Online (Sandbox Code Playgroud)


但是我对如何制作感到困惑:

print "Sorry, your password does not meet our criteria."
Run Code Online (Sandbox Code Playgroud)

和:

print "Congratulations, your password meets our criteria." 
Run Code Online (Sandbox Code Playgroud)

这两句话表明正确.

我打算每天展示"Warning!..."沿"Sorry,..."时,其中一个条件不符合,而节目"Congratulation,..."当所有的条件都满足.
但是凭借我拥有的东西,"Sorry,..."线条将始终显示并且"Congratulations,..."线条未显示.

我知道我一定做错了但我怎么能解决这个问题呢?
谢谢!

Ale*_*der 5

创建一个包含密码中所有错误的列表.如果有错误,请说明密码不符合条件,然后打印所有密码错误类型.否则,打印它符合标准.

def check_password(password):
    errors = []
    if not has_unique_letters(password):
        errors.append("Warning! Please ensure letters are not repeated.")
    if not has_even_vowels(password):
        errors.append("Warning! Please ensure password contains an even number of vowels.")
    if not has_special_character(password):
        errors.append("Warning! Please ensure password contains at least one of {@, #, *, $}")
    if not has_divisible_numbers(password):
        errors.append("Warning! Please ensure all numbers are divisible by 2 or 3.")
    if errors:
        print "Sorry, your password does not meet our criteria."
        for e in errors:
            print(e)
    else:
        print "Congratulations, your password meets our criteria."

password = raw_input("Please set your password:")
check_password(password)
Run Code Online (Sandbox Code Playgroud)