I currently have a dictionary
and a list
, and I would like to subtract the list values from the respective dictionary values (based on index position). This is what I have tried so far:
dict1 = {
"appel": 3962.00,
"waspeen": 5018.75,
"ananas": 3488.16
}
number_fruit = [
3962,
5018.74,
3488.17
]
dictionary_values = list(number_fruit)
list_values = list(dict1.values())
are_values_equal = dictionary_values == list_values
But this only returns True
or False
if there is a difference.
But what I want to achieve is to return the difference between number_fruit
list and dict1
dictionary, only if the difference is not equal to zero..
Here is the expected output:
waspeen : 0.01
ananas : -0.01