C3-W1-#6 (Cant figure out the problem)

I keep getting this error:
UnboundLocalError: local variable ‘probability_f’ referenced before assignment

I saw a couple of posts but was not helpful. My sample code for this exercise is:


for feature_val, feature_name in zip(X, features):
    # Match the current feature based on its name
    match features:
        case "height" | "weight": 
            # Get the relevant parameters out of the params_dict dictionary
            mu = params_dict["breed"]["height" | "weight"]["mu"]
            sigma = params_dict["breed"]["height" | "weight"]["sigma"]
   Thank you in advance
  1. Please don’t post your code on the forum. That’s not allowed by the Code of Conduct.

  2. The code you posted doesn’t use probability_f. So that segment is probably not where the error is.

  3. I don’t think using an or-operator there is the correct behavior.

  4. What does your code do if “features” is not “height” or "weight? Does it try to use probability_f?

  5. Consider why “features” might have a value that doesn’t match any of your cast statements.