I'm trying to create a login panel in the command line using python. so if the user does not insert any username, the cursor should remain on the same line but I should get an error on the next line.
I tried:
while True:
input1 = input('username: ')
if len(input1) == 0:
print("Sorry, your response was not loud enough.")
continue
input2 = stdiomask.getpass('pasword: ')
if len(input2) == 0:
print("Sorry, your response was not loud enough.")
continue
input3 = stdiomask.getpass('cnf password: ')
if len(input3) == 0:
print("Sorry, your response was not loud enough.")
continue
But since I'm using while loop so if I'm not inserting password I have to insert username again which I don't want also if I don't insert a username, the username is prompted on next line after showing error. so Is there any way to handle these situations?
something like this:
F:\new_file\file> python main.py
? username: # cursor remains here until a username is inserted
> Invalid input # error is prmpted on next line