import getpass


def newPassword(prompt='Password: '):
    """Securely obtain a new password from the user."""
    while True:
        p = getpass.getpass(prompt)
        if p == getpass.getpass('Confirm password: '):
            return p
        else:
            print('Passwords do not match. Try again.')