When I use this it includes 95 too. I think the code skips one item than adds the other. Can anyone explain why?
roll_number = [47, 64, 69, 37, 76, 83, 95, 97]
sample_dict = {'Jhon':47, 'Emma':69, 'Kelly':76, 'Jason':97}
res = sample_dict.values()
for i in roll_number:
if i not in res:
roll_number.remove(i)
print("After removing unwanted elements from list", roll_number)