I'm very new to Python and I'm struggling with this error, here is my code:
new_dictionary = dict(((i,f), abs(int(-d/-(-first_dictionary[i, f]//second_dictionary[i, f])))) for i in I for f in F)
I get in return this: ZeroDivisionError: float division by zero
I know that this error occurs because some values of first_dictionary and of second_dictionary are equal to 0.0, but I don't know how to manage it.
I tried to define this function:
def my_function(dict1, dict2):
    first_dictionary = dict1
    second_dictionary = dict2
    for i in I:
        for f in F:
            if first_dictionary[i, f] == 0 or second_dictionary[i, f] == 0.0:
                new_value = 0
            else:
                new_value = abs(int(-d/-(-first_dictionary[i, f]//second_dictionary[i, f])))
    return new_value
new_dictionary = dict(((i, f), my_function(first_dictionary, second_dictionary)) for i in I for f in F)
But the output is different from what I expected, it gives me the same value for all key in the dictionary.
How can I resolve this error? Thanks in advance!
 
     
     
    