Ask coding questions

← Back to all posts
Can someone help me fix this indentation?
AHulot (43)

I am sure I typed the code correctly but it keeps saying that it is wrong. Does anyone know how I can fix it?

def login():
global wks
while 1:
user = input("Please enter your Username: ")
passW = input("Please enter your Password: ")
t1 = wks.find(user)
cprint("Invalid username. Please try again or create a new account.",)
if wks.cell(t1.row, t1.col+1).value == passW:
print("Login successful. Welcome back.")
print("Login successful. Welcome back.")
print("Incorrect password")

malvoliothegood (728)

It's annoying. The indentation error is hidden. Here is the fix that worked for me:

  • Highlight all the code inside the login function
  • Hold the Shift key down and press Tab a couple of time to unindent the code
  • With the code still highlighted press Tab a couple of times
  • Then highlight the code inside the while loop and press Tab once to indent it
AHulot (43)

@malvoliothegood :
I'm not entirely sure how it's not working after I tried that. I will let you edit the repl?

AHulot (43)

@AHulot :
Hold on, I think I fixed it : )