-1

I am sorry but i have a problem that i dont understand...

def login_screen():
    print(30 * "-")
    print("   LOGIN")
    print(30 * "-")
    username = print("Please enter your username: ")
    password = print("Please enter your password: ")
        with open('logins.txt', 'r') as csvfile:
            loginreader = csv.reader(csvfile, delimiter=',', quotechar= None)
            for codes in loginreader:
                if len(codes) == L_LEN:
                    if codes[L_USERNAME] == username and codes[L_PASSWORD] == password and codes[L_ADMIN] == "Yes":
                        admin_console()
                    elif username == row[L_USERNAME] and password == row[PASSWORD] and row[L_ADMIN] == "No":
                        #Temp normal console here
                    else:
                        clearscreen()
                        error_head()
                        print("Unknown account")
                        input("Press [ENTER] To continue...")
                        login_screen()
                elif len(codes) != M_LEN:
                    next(csvfile, None)

So the problem is that it comes with the following error:

  File "G:\Python\DatabaseStandardRewrite\Login.py", line 49
else:
   ^

IndentationError: expected an indented block

But i dont get it! (Yes, all the other things are defined in the rest of the document!

Does anyone of you see my mistake?

Natan

3
  • I have in my code, not in this website? Commented Mar 2, 2017 at 15:41
  • then it's probably TAB/space mixup. Convert tabs to spaces and check the output. Commented Mar 2, 2017 at 15:42
  • How do i do this(Yes i am new to Python) Commented Mar 2, 2017 at 15:43

1 Answer 1

2

Python does not permit blocks to be empty; you need at least one statement, and a comment does not count. So in the elif block before your else, you should put pass.

            elif username == row[L_USERNAME] and password == row[PASSWORD] and row[L_ADMIN] == "No":
                #Temp normal console here
                pass
            else:
                clearscreen()
Sign up to request clarification or add additional context in comments.

2 Comments

If this is the correct answer, please accept it as the correct answer.
In this case, because the conditional statement is inside a cycle, you can also use continue to make the elif block not empty, IF you want to skip directly to the next iteration of your cycle. In this example it ends up being equivalent as nothing else is done after the pass (other conditional branches don't apply).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.