help fixing my password detetcor code in python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

help fixing my password detetcor code in python

Hello, i dont know if thos was the appropriate place but im having trouble with my code saying the "break is outside the loop and all i can see is that my indentations are fine and it looks as though its in the if loop. what am i not seeing? #password strength detector import re, sys print("""check how strong your password is. it needs to be 8 characters long, contain both upper and lowercase characters and have at least one digit""") def passWordDetect(x): #8 characters long text = re.compile(r"[a-zA-Z0-9.\%]{8,}") text.search(x) if text.search(x) == None: print("Your password needs to be at least 8 characters long") else: break #one upper and lower text = re.compile(r"[A-Z]") text.search(x) if text.search(x) == None: print("Your password needs to contain at least one Upper and lower case characters") else: break # at least 1 digit text = re.compile(r"\d+") text.search(x) if text.search(x) == None: print("Your password needs to contain at least one number") else: print("Strong password") x = input("press ENTER to quit") if x == "": print("Quitting...") sys.exit() passWordDetect(x)

14th Oct 2023, 11:03 PM
Eric
3 Answers
+ 1
"break" is used only in loops.
14th Oct 2023, 11:19 PM
Solo
Solo - avatar
0
Ahh thank you
14th Oct 2023, 11:50 PM
Eric
0
Unnecesssary breaks. No loops no breaks
17th Oct 2023, 8:07 PM
Werg Serium
Werg Serium - avatar