-2
user = "admin"
password = "admin"
while true:
    ques1 = input("Enter your username: ")
    ques2 = input("Enter your password:")
 if ques1 == user and ques2 == password :
     print("Welcome")
     break
 else :
     print("username or password are wrong ! \nplease try again !")

python 3.7 while true loop gives error about unindent does not match any outer indentation level error on line 3

  • 2
    You have spaces before the `if` and `else` statements which shouldn't be there. Voting to close as just a typo. – kaya3 Nov 05 '19 at 22:53
  • See [this question](https://stackoverflow.com/questions/492387/indentationerror-unindent-does-not-match-any-outer-indentation-level) – SuperStormer Nov 05 '19 at 22:55
  • Or maybe the extra spaces whereby `ques1` and `ques2` assignments are indented further than the `if`s are the ones that are wrong (and those two lines should only have a single space at the front, the same way the `if` and `else` do); it's a question of authorial intent. (That said, best practice is to follow PEP-8 and only use 4-space indents, without a compelling reason to do otherwise). – Charles Duffy Nov 05 '19 at 22:55
  • still give me same error , i delete the line 3 (while true:) and code is working , – uyghur coder Nov 05 '19 at 23:01

1 Answers1

0

Your indent is bad, are you using an IDE ?? Your code should look like the below, also it's while True, not true.

user = "admin"
password = "admin"
while True:
    ques1 = input("Enter your username: ")
    ques2 = input("Enter your password:")
    if ques1 == user and ques2 == password :
        print("Welcome")
        break
    else :
        print("username or password are wrong ! \nplease try again !")
5x shanks
  • 116
  • 6
  • thanks for the help! now code is working , I'm using the visual studio code and i trun off the auto fix, that's where I'm wrong – uyghur coder Nov 05 '19 at 23:07
  • 1
    Try to use the auto-correction, or go for something more user friendly as pyCharm. The correction helps you learn and memorize the structure of the language syntax more. – 5x shanks Nov 05 '19 at 23:18