Would someone please help me.
Why does this?
return [lst1.index(x) for x in lst1 if lst2[lst1.index(x)] == x]
print(same_values([5, 1, -10, 3, 3], [5, 10, -10, 3, 5]))
[0, 2, 3, 3]
The last value is a repeat, and I can’t work out why it does this. I have tried this same thing a few different ways, and the code above returns the fewest repeats.
Please ignore the indentation of the return that is an error related to formatting restrictions of this forum rather than something I have overlooked.