I have a slight problem with this exercise. So far I’m at designing pseudocode for it but I have no idea what syntax I should use to put index on a new list. Every method I’m thinking of will put on my list a value that is stored at said index, not the index itself. Any idea how to do it?
What pseudo code do you have so far? I don’t want to spoil too much in one go, so i am first awaiting your pseudo code. Hope you understand
define function(lst1, lst2):
create empty list to store indexes
for every element of lst1:
compare element to element at same index in lst2
if they are the same:
emptylist.append(index)
return empty list
HA! I just did it, I might not be so stupid after all There’s one simple trick to it:
def same_values(lst1, lst2):
lst0 = []
i=0
for ind in lst1:
if lst1[i]==lst2[i]:
lst0.append(i)
i+=1
return lst0
1 Like
This topic was automatically closed 18 hours after the last reply. New replies are no longer allowed.