<filename>name_list_py.py

list = ["melih","merve","cansin"]

def add_person():
    person = input("Please enter the name of the person that you want to add into the list : \n")
    list.append(person)
    return list

def delete_person():
    person = input("Please select the name for the person who is going to be deleted : \n")
    for i in list:
        if person == i:
            list.pop(list.index(i))
    return list

def modify_person():
    modified_person = input("Please select the name for the person who is going to be modified : \n")
    new_person = input("Please select the name for the new person  : \n")
    for i in list:
        if i == modified_person:
            list.insert(list.index(i), new_person)
            list.pop(list.index(i))
    return list

def print_actual_list():
    for i in list:
        print(int(list.index(i))+1,"\t",i)

def print_to_file():
    f= open("list.txt", "a")
    f.writelines(list)
    f.close()

def main():
    print_actual_list()
    operation = input("what is your operation : \na) Add person\nb) Delete person\nc) Modify Person\n")
    if operation == "a":
        add_person()
    elif operation == "b":
        delete_person()
    elif operation == "c":
        modify_person()
    else:
        print("wrong operation !!!!\n")
    print_actual_list()
    print_to_file()
main()


