#######################################################################
# Add a contact to a contact file
#######################################################################
def add_contact():
    lname = input("Enter last name.....: ")
    fname = input("Enter first name....: ")
    addr  = input("Enter street address: ") or '-'              #if nothing is entered use '-'
    email = input("Enter email address.: ") or '-'
    phone = input("Enter phone number..: ") or '-'

    if not lname: lname = '-'                                   #if nothing is entered use '-'
    if not fname: fname = '-'

    record  = F"{lname}//{fname}//{addr}//{email}//{phone}"     #concatenate input with // delimiters
    record += "\n"                                              #make sure you add a newline \n

    contact_file.write(record)                                  #write the record


### main code ############################################################

file  = input("Enter Contact file name: ")
if not file:                                            #if nothing was entered
    file = "data/contact.file"

contact_file = open(file,'a')                           #open the file for appending

resp='y'

while(resp=='y'):
    add_contact()                                       #call add_contact function
    resp = input("Add another (y/n)? ")
    resp = resp[0:1]                                    #take first char of the response only
    resp = resp.lower()                                 #convert into lower case                                         
        
contact_file.close()                                    #close the file