I need to know how can I make my program continue with the login ONLY if the entered username is valid, but if an incorrect username is entered it should stop, but the break function just doesn't work.
I am a beginner, and I am truly sorry about posting about something this simple, but I cant get it to work and I cant find a direct answer elsewhere.
Code:
if a == x:
print('entered username is valid')
else:
print('entered username is invalid')
break
I tried using {}, and it didn't quite work; it said something about just not working properly but the brackets don't work in any scenario.
while a!="":
if a!=x:
print("username invalid")
break
else:
print("username login valid")
b=str(input("enter password"))
if b==y:
print("logged in successfully")
break
you can work with something similar, break are only for loops , you should integrate it with while/for loop, for this example we entered in a loop that loos on while your "a" username input is not empty