I am having a tough time with this one.
I’ve written a nested for loop which I’m not sure is even the correct method, but I think I have my condition correct as well as the append. My return may be a little suspect.
It’s returning [0, 0, 2, 3, 4] but should be returning [0, 2, 3]. I’m not sure how that even makes sense.
Write a function named
same_values()that takes two lists of numbers of equal size as parameters.
The function should return a list of the indices where the values were equal in
lst2. For example, the following code should return
[0, 2, 3]
same_values([5, 1, -10, 3, 3], [5, 10, -10, 3, 5])
Here is my code:
#Write your function here def same_values(lst1, lst2): new_lst =  for index in range(len(lst1)): for index2 in range(len(lst2)): if lst1[index] == lst2[index2]: new_lst.append(index) return new_lst #Uncomment the line below when your function is done print(same_values([5, 1, -10, 3, 3], [5, 10, -10, 3, 5]))