This is a registration and login program I made in Python that runs through the terminal. I am new to programming so I didn't have any actual use for this, I simply made it for practice. Please give me tips on minimizing code and making things shorter, point out any bad programming practices I used here and how I can change them and look out for them next time.# Import modulesimport time# All accountsusers = {    root: {        password: gucci-mane,        group: admin,        mail: []    }}# Form validationdef validate(form):    if len(form) > 0:        return False    return True# Login authorizationdef loginauth(username, password):    if username in users:        if password == users[username][password]:            print(Login successful)            return True    return False# Logindef login():    while True:        username = input(Username: )        if not len(username) > 0:            print(Username can't be blank)        else:            break    while True:        password = input(Password: )        if not len(password) > 0:            print(Password can't be blank)        else:            break    if loginauth(username, password):        return session(username)    else:        print(Invalid username or password)# Registerdef register():    while True:        username = input(New username: )        if not len(username) > 0:            print(Username can't be blank)            continue        else:            break    while True:        password = input(New password: )        if not len(password) > 0:            print(Password can't be blank)            continue        else:            break    print(Creating account...)    users[username] = {}    users[username][password] = password    users[username][group] = user    users[username][mail] = []    time.sleep(1)    print(Account has been created)# Send maildef sendmail(username):    while True:        recipient = input(Recipient > )        if not len(recipient) > 0:            print(Recipient can't be blank)            continue        elif recipient not in users:            print(There is no account with that username)            continue        else:            break    while True:        subject = input(Subject > )        if not len(subject) > 0:            print(Subject can't be blank)            continue        else:            break    while True:        context = input(Context > )        if not len(context) > 0:            print(Context can't be blank)        else:            break    print(Sending mail...)    users[recipient][mail].append([Sender:  + username, Subject:  + subject, Context:  + context])    time.sleep(1)    print(Mail has been sent to  + recipient)# User sessiondef session(username):    print(Welcome to your account  + username)    print(Options: view mail | send mail | logout)    if users[username][group] == admin:        print()    while True:        option = input(username +  > )        if option == logout:            print(Logging out...)            break        elif option == view mail:            print(Current mail:)            for mail in users[username][mail]:                print(mail)        elif option == send mail:            sendmail(username)        elif users[username][group] == admin:            if option == user mail:                print(Whos mail would you like to see?)                userinfo = input(> )                if userinfo in users:                    for mail in users[userinfo][mail]:                        print(mail)                else:                    print(There is no account with that username)            elif option == delete mail:                print(Whos mail would you like to delete?)                userinfo = input(> )                if userinfo in users:                    print(Deleting  + userinfo + 's mail...)                    users[userinfo][mail] = []                    time.sleep(1)                    print(userinfo + 's mail has been deleted)                else:                    print(There is no account with that username)            elif option == delete account:                print(Whos account would you like to delete?)                userinfo = input(> )                if userinfo in users:                    print(Are you sure you want to delete  + userinfo + 's account?)                    print(Options: yes | no)                    while True:                        confirm = input(> )                        if confirm == yes:                            print(Deleting  + userinfo + 's account...)                            del users[userinfo]                            time.sleep(1)                            print(userinfo + 's account has been deleted)                            break                        elif confirm == no:                            print(Canceling account deletion...)                            time.sleep(1)                            print(Account deletion canceled)                            break                        else:                            print(confirm +  is not an option)                else:                    print(There is no account with that username)        else:            print(option +  is not an option)# On startprint(Welcome to the system. Please register or login.)print(Options: register | login | exit)while True:    option = input(> )    if option == login:        login()    elif option == register:        register()    elif option == exit:        break    else:        print(option +  is not an option)# On exitprint(Shutting down...)time.sleep(1)
Register/Login and authentication through terminal
python;authentication