W1_UNQ_C8 float division by zero

I have a problem with this exercise. In the c_statistic function, once I call the previous function to calculate the c_for_benefit_score I get the error:

—> 54 cstat = (concordant_count+0.5*risk_tie_count)/permissible_count

ZeroDivisionError: float division by zero

I checked the “pairs” list was generated correctly, however it differs from the tuple type to c_for_benefit_score because it has 3 variables per patient (and not just two like the previous function). In any case it should work because in c_for_benefit_score I call the pairs list only in its first two variables, so the third column should not be considered. Could it be an error in passing the list from c_statistic to c_for_benefit_score ?

Hello Alberto,

When I had this error while doing the assignment, I went to check if my permissible count is coming to 0 and how to do address it as that is causing ZeroDivision error.

Yes but it seems that the test is actually correct and gives me as values obs_benefit = [0,0,0,0] but it is absolutely correct if actually the pairs given by the test are [((0. 1, 0, 0), (0.9, 0, 1)), ((0.3, 0, 0), (0.5, 0, 1)), ((0.2, 1, 0), (0.8, 1, 1)), ((0.4, 1, 0), (0.6, 1, 1))) (the comparison is to be done in the second variable of each patient). When then the check is done if obs_benefit[i] != obs_benefit[j] I will actually have permissible_count = 0

Alberto can you share a complete image of the error log you got?

Your error is UNQ_C8?

It seems your error is UNQ_C7??

or you can send your codes via personal DM, click on my name and then message.