I have been creating a program and I want it to check when a password is weak, medium or strong. I have defined each one of the uppercase, lowercase and digits so the program can check if the pass's strength. I have set it so a+b+c (all flags) is strong etc. but when I enter 7 characters, all lowercase it just restarts my program. I need it to tell me the password is weak etc. If anyone could give me any hints I would be grateful! Thanks!
import sys
import os
def checkPass():
passLoop = True
while passLoop:
print("Welcome user!")
x = len(input("Please enter your password, between 6 and 12 characters. "))#Asks for age
if x <= 6 or x >= 12:
print("Your password is the wrong length.")
r = input("Please press any key to restart the program")
passLoop = False
checkPass()
###########################
def upperCase(x):
for char in x:
if char.isupper():
return(1)
return(0)
###########################
def lowerCase(x):
for char in x:
if char.islower():
return(1)
return(0)
###########################
def digitFlag(x):
for char in x:
if char.isalnum():
return(1)
return(0)
###########################
def passStrength():
a = upperCase
b = lowerCase
c = digitFlag
totalValue = a + b + c
if totalValue == a or b or c:
print("Your password is weak, please re-enter it!")
if totalValue == a and b or a and c or b and c:
print("Your password is medium, please re-enter it!")
if totalValue == a and b and c:
print("Your password is strong, please re-enter it!")
passStrength()