-2

Struggling with this one. Only a beginner so go easy on me! :) Trying to have user input password and if not within 6-10 characters. They are asked to input again. When password correct the loop stops. I can’t seem to get it to exit the loop even if correct lenght password entered.!

min_password_lenght = 6
max_password_lenght = 10

password = input(“enter password:”)
password_lenght = len(password)

while password_lenght > 6 or password_lenght < 10:
          print(“error”)
          password = input(“enter again:”)

print (“password correct”)
David Buck
  • 3,752
  • 35
  • 31
  • 35
  • 1
    You're going to need to paste the text version of your code in the body of your question, the image is near unreadable and is not the recommended way to ask a question. – PacketLoss Sep 04 '20 at 05:00
  • 1
    You do not update `password_length` and check for the wrong range. – DYZ Sep 04 '20 at 05:09
  • https://stackoverflow.com/questions/23294658/asking-the-user-for-input-until-they-give-a-valid-response – Prune Sep 04 '20 at 05:28

1 Answers1

1

You should probably be more specific next time, but here's a snippet that satisfies what you described:

pwd = ""
while len(pwd) < 6 or len(pwd) > 10:
    pwd = input("Enter password: ")
General Poxter
  • 554
  • 2
  • 8