-4

I was making a password project for school and i got stuck on one problem. Here is the code the isnt working properly:

def passwordStrength(password):
    if password.islower():
        print("Your password is weak as it only contains lower case letters")
    elif password.isupper():
        print("Your password is weak as it only contains capital letters")
    elif password.isnumeric():
        print("Your password is weak as it only contains numbers")
    elif password.islower and password.isupper:
        print("Your password is medium as it contains no numbers")
    elif password.islower and password.isnumeric:
        print("Your password is medium as it contains no uppercases")
    elif password.isupper and password.isnumeric:
        print("Your password is medium as it contains no lowercases")
    elif password.islower and password.isupper and password.isnumeric:
        print("Your password is strong")

but if i type in a password such as "asasASAS1212" it says it contains no numbers

4
  • islower is a function, not a property (etc). Commented Dec 15, 2016 at 13:13
  • You're not calling islower and others Commented Dec 15, 2016 at 13:13
  • 2
    Also, the duplicates suggested on your classmates question may help further Commented Dec 15, 2016 at 13:15
  • 1
    There is a big difference between if some_method : and if some_method() :. Commented Dec 15, 2016 at 13:16

1 Answer 1

3

The first issue with your code is that you are not calling the methods themselves. In essence, you need to put brackets (i.e. ()) after each reference to islower, isupper and isnumeric.

A deeper issue lies in the intention behind your usage of those methods, though. Functions islower, isupper, isnumeric do not semantically mean "this string has lowercase alphabetical characters", "this string has uppercase alphabetical characters" and "this string has numerical characters", respectively. Those functions check whether the entire string consist solely of such characters.

So, if there is a single digit in the string(e.g. "asd123"), method islower returns false, because there are characters in that string that are not a lowercase letter.

A solution to that problem, and not a very efficient one, is checking each character in the string individually.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.