Removing an index number from a list/csv using input

33 Views Asked by At

i'm doing an exercise for school where you use python to store client details in a csv and i'm having trouble with adding a way for the user to delete their client details as pop won't accept anything but an index number - can someone help me find a way to do this? I'm really new to coding sorry.

Here's my code:

if first_name in name:
    for x in range(0,len(existing_clients)):
        if first_name == existing_clients[x][0]:
            print(existing_clients[x])
            index = existing_clients.index(existing_clients[x])
            print(index)
            existing_clients.pop(index)

The above works to print out the index number but I don't know how to make it delete the client details from the list/csv. I feel like i'm missing something really obvious and stupid.

Here's an example of the csv data making up existing_clients:

Ave,O' Hogan,Ms,Male,13/04/2022,Help Desk Operator,1285.66,64.80
Ariel,Fidge,Honorable,Female,15/09/2022,VP Quality Control,8.27,82.63
Timoteo,McGowing,Dr,Male,03/12/2021,General Manager,1751.11,23.92
Lezley,Wilmott,Mr,Male,04/07/2022,Statistician I,350.05,74.83
0

There are 0 best solutions below