Icstaz Icstaz - 4 months ago 9
Python Question

A program which creates emails

I'm having trouble creating a program which takes a list of first names and a list of last names, appends the two lists and adding @abc.mail.com
I haven't touched python in months so I don't even know what to do anymore. I tried creating lists and dictionaries but I don't know if it's even possible to input more than one string at a time.
To summarize:
I want a program that asks for a user to input a list for firstName, a list for lastName and then the program to append it together to make firstName.lastName@abc.mail.com
I appreciate any help that you give.

Answer
#!/usr/bin/env python
# -*- coding: utf-8 -*-

def fill_list(l, promt):
    while True:
        x = input(promt)
        if not x:
            break

        l.append(x)

if __name__ == '__main__':
    first_names = list()
    last_names = list()

    fill_list(first_names, "Input first name: ")
    print('first_names: {}'.format(first_names))

    fill_list(last_names, "Input last name: ")
    print('last_names: {}'.format(last_names))

    for first, last in zip(first_names, last_names):
        print('{}.{}@abc.mail.com'.format(first, last))

Output:

Input first name: fff
Input first name: ddd
Input first name: ggg
Input first name: 
first_names: ['fff', 'ddd', 'ggg']
Input last name: 111
Input last name: 222
Input last name: 333
Input last name: 
last_names: ['111', '222', '333']
fff.111@abc.mail.com
ddd.222@abc.mail.com
ggg.333@abc.mail.com