Ask coding questions

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

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: ")
try:
t1 = wks.find(user)
except:
cprint("Invalid username. Please try again or create a new account.",)
continue
if wks.cell(t1.row, t1.col+1).value == passW:
print("Login successful. Welcome back.")
print("Login successful. Welcome back.")
else:
print("Incorrect password")

Commentshotnewtop
malvoliothegood (365)

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 (17)

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

AHulot (17)

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