import string
import random

#code to get user details
def get_details():
    first_name = input("Enter your Firstname: \n")
    last_name = input("Enter your Lastname: \n")
    email_add = input("Enter your Email address: \n")

    user_details = [first_name, last_name, email_add]

    return user_details

#code to generate a random password from user details
def gen_password(details):

    characters = string.ascii_letters
    length = 5
    random_password = ''.join(random.choice(characters)for i in range(length))
    password = str(details[0][0:2] + details[1][-2:] + random_password)

    return password

# code to create a container housing user details
status = True
container =[]

while status:

    #code to get user details
    details = get_details()

    #code to show generated password
    password = gen_password(details)
    print("Your password is: " + str(password))

    #code to ask user if he/she would like to continue using the autogenerated password
    password_like = input("Do you like your generated password. If yes enter Yes, if no enter No and supply your preferred password \n")
    password_loop = True

    while password_loop:

        if password_like == "Yes":
            #code to add autogenerated password to user details
            details.append(password)

            #code to add user details to container
            container.append(details)

            password_loop = False

        else:
            #user is to enter a password with longer than or equals 7 characters
            user_password = input ("Enter a password with longer or equals 7 characters \n")

            #code to create a password length loop

            pass_length =  True

            while pass_length:

                if len(user_password) >= 7:

                    #code to add password chosen by user to user details
                    details.append(user_password)

                    #code to add user details to container
                    container.append(details)

                    pass_length = False

                    password_loop = False

                else:
                    print("You entered a password with less than 7 characters")

                    user_password = input ("Enter a password with longer or equals 7 characters \n")

    #for a new user
    new_user = input ("Would you like to enter a new user? Yes or No \n")

    if (new_user == "No"):

        status = False
        for item in container:
            print(item)

    else:
        status = True


