I have the following list: which stores index references (read in from a file).
easy_answers=[row[ca],row[1],row[2],row[3],row[4]]
Example values:
row[ca] = 1 #this is a flag that points to the right response, in this case row1 which is a
row[1] = a
row[2] = b
row[3] = c
and so on
All I want to do is simply check the list to see if the index of any of the held list elements are the same (duplicate), and if so, remove the duplicate index (but leave in the row[ca] value, as that is the correct answer)
In the above example, the expected output would be:
easy_answers=[row[ca],row[1],row[2],row[3],row[4]]
#we know from the values that row[ca] = 1 and row[1] =1, so remove row[1]
..So the final output would be:
easy_answers=[row[ca],row[2],row[3],row[4]]
Code
Removing a duplicate from a list when dealing with just values is simple, but how do I change the code below to search for the values held by the index numbers to achieve the same thing?
ca=int(row[5]) #this is the right resopnse for the question
easy_answers=[row[ca],row[1],row[2],row[3],row[4]]
if row[ca] in easy_answers:
easy_answers.remove(row[ca])