name = "python"
name_answer = input("What is the name ? ")
while name_answer != name:
input("No ! Again, What is the name ? ")
else:
print("Correct answer")
If my first answer is "python", I get "correct answer". Untill then, everything is ok.
If I start with a false answer, for instance I input "abcd", the input "No ! Again, what is the name ? " appears. Here also, everything is OK.
But, the issue is I get stuck in the loop "No ! Again, what is the name ? " even if after that, I put the correct answer ("python").
I don’t understand, I would like to get out that loop once I put "python" as an input even if I’m starting to input a false answer like "abcd".
>Solution :
The second input of the user (input("No ! Again, What is the name ? ")) wasn’t assigned to the name_answer variable
name = "python"
name_answer = input("What is the name ? ")
while name_answer != name:
name_answer = input("No ! Again, What is the name ? ")
else:
print("Correct answer")