dimanche 1 octobre 2017

Trying to check a string that satisfies these conditions

Trying to use following code to check a string:

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)

However I am confused about how to make "print "Sorry, your password does not meet our criteria."" and "print "Congratulations, your password meets our criteria."" these two sentences show correctly. I intend to show every "Warning,..." along with "Sorry,..." when one of these conditions is not meet, while show "Congratulation,..." when all of conditions are meet. But with what I have, "Sorry,..." line will always shows and "Congratulations,..." line is not showing. I know I must done wrong but how can I fix this? Thanks!

Aucun commentaire:

Enregistrer un commentaire