I have been trying this for a few days now. I have to read in a file containing zoo animals. (i.e. ['ID', 'Name', 'Species']) Next, have to accept the user's ID choice and delete from the list. This is what I so far. I am stuck and can't proceed further until this section is complete. I appreciate any comments. Also using python 3.
f = open('ZooAnimals.txt', 'r') #read in file
file = [line.split(',') for line in f.readlines()] #turn file into list
c = input("What ID would you like to delete? ") #accept user input
file1 = list(c)#turn user input into a list item
list.pop(file1) #suppose to pop out the value
print(file)
EDIT:
The file contains the following items for example. [['1', 'Whiskers', 'Siberian Tiger\n'], ['2', 'Babbity', 'Belgian Hare\n'], ['3', 'Hank', 'Spotted Python\n'], ['17', 'Larry', 'Lion\n'], ['10', 'Magilla', 'Eastern Gorilla\n'], ['1494', 'Jim', 'Grizzy Bear\n']]
I want to try and delete for example, ID 2, Babbity, Belgian Hare
This is what I can't do with my current code
list(e.g. for an assignment), or can you use a more appropriate data structure?