I have did a little research around "Google", "YouTube", "Facebook" and "Stack Overflow" and I haven't found what I was looking for. So, I need your guidance. :)
I want program to ask user input "PASSWORD" and every time user inputs wrong password the program asks password again, and again, and again until user types the correct password. Let's say that the password is as simple as "abc123".
So, I start the program and it asks to input: "PASSWORD: ". If user types "abc123" then program prints "GOOD PASSWORD". If user types anything what is not "abc123" then program prints "BAD PASSWORD". As simple as that.. for now.
My best attempt:
#SECTION1_ASKING
passwordInput=input('PASSWORD: ')
password='abc123'
while password == passwordInput:
print('GOOD PASSWORD')
break
else:
print('BAD PASSWORD')
passwordInput=input('PASSWORD: ')
#SECTION2_RE-ASKING
while False:
while password == paswordInput:
print('GOOD PASSWORD')
else:
print('BAD PASSWORD')
passwordInput=input('PASSWORD: ')
but I either make password asked once or twice or I stuck in Infinite while Loop.
raw_input(), which is Python 2, and one usedinput(), which is Python 3 (the Python 2 version ofinput()has a different use). Which version of Python are you using?whileandforare looping constructs, it seems you are mistaking them withifor at least mixing those up, because they all can be combined withelse. BTW, one advise: Write a plan in plain language first, so that anyone could understand it and follow it even without any programming knowledge. Keep this plan in the comments of your code.ifruns code for once,whileruns code over and over again,forruns code certain amount of times, andelsejust runs code instead of condition that is set onif,whileorforcode. Since I have an answer of my issue I going to analyze my mistake deeper. I feel that I need to practice more on these(if,while,for) and get comfortable using them before I move on.