For example,
test_list_1 = [{key_1:val_1},{key_2:val_2},{key_3:val_3},{key_4:val_4}]
test_list_2 = [{key_3:val_3},{key_4:val_4},{key_5:val_5},{key_6:val_6}]
# Desired Value
# # test_list_2 - test_list_1 = [{key_5:val_5},{key_6:val_6}]
When there are two lists including dictionaries, Is there any way to subtract test_list_1 from test_list2?
python list dictionary
If you use list compression as shown below, you can express it briefly.
[item for item in test_list_2 if not item in test_list_1]
© 2024 OneMinuteCode. All rights reserved.