Aug-25-2020, 01:34 PM
(This post was last modified: Aug-25-2020, 01:35 PM by deanhystad.)
No syntax error when I run your code. Some logic and programming errors.
The argument to the function is not used anywhere
The argument to the function is not used anywhere
def create_password(tmp):To call a function you need to use parenthesis. The code below does not call isupper
x = 'a' print(x.isupper)
Output:<built-in method isupper of str object at 0x00000179EB55C370>
In Python indentation is not just to make things look pretty. Indentation is how code blocks are defined. In the code below the for loop is not inside the while loop.while try_again == True: if length >= 8: # if password has more than 8 characters add 1 to the score score = score + 1 for x in password:The function returns a value that is never defined.
return New_passwordI think the logic could use some work too. Doesn't it feel like there are a lot of steps in calculating the score? A small change like using 1/0 instead of True/False can make a big difference:
upper = lower = digit = special = islong = 0 if len(pwd) > 7: islong = 1 for c in pwd: if c.isupper(): upper = 1 if c.islower(): lower = 1 if c in digits: digit = 1 if c in specials: special = 1 score = upper + lower + digit + special + islongAnd "in" works with strings as well as lists.
digits = "0123456789" specials = "!£$%^&*()@?#"