fork download
  1. list_a = [1.1, 3.3, 5.5]
  2. list_b = [2.2, 4.4, 6.6]
  3.  
  4. test_dict = {
  5. 1: 1.1,
  6. 2: 2.2,
  7. 3: 3.3,
  8. 4: 4.4,
  9. 5: 5.5,
  10. 6: 6.6,
  11. }
  12.  
  13. new_dict = {key: value for key, value in test_dict.items() if value in list_a}
  14. print (new_dict)
Success #stdin #stdout 0.01s 9992KB
stdin
Standard input is empty
stdout
{1: 1.1, 3: 3.3, 5: 5.5}