mercredi 3 janvier 2018

my two python functions are overriding each other?

These are my two functions

def upper_score(test_string, aScore):
  if re.match(a, test_string):
    aScore = increase_score(5, aScore)
    print (aScore)
    print("UPPERCASE")
  else:
    print("The password needs capital letters for a higher score")

def lower_score(test_string, aScore):
  if re.match(b, test_string):
    aScore = increase_score(5, aScore)
    print (aScore)
    print("LOWERCASE")
  else:
    print("The password needs lowercase letters for a higher score")

If I input all upper case letters I get this output:

5
UPPERCASE
The password needs lowercase letters for a higher score

If I input all lower case letters I get this output:

The password needs capital letters for a higher score 5 LOWERCASE

These results I am happy with.

THE PROBLEM IS when I combine uppercase and lowercase letters I get this result:

The password needs capital letters for a higher score
5
LOWERCASE

1) Even though there are both uppercase and lowercase letters the score is still 5 instead of 10 2) The regex for uppercase letters stops working even though there are uppercase letters in the string

Thank you!!! I hope i explained this well.

Aucun commentaire:

Enregistrer un commentaire