Python Control Flow: Medical Insurance Project - Task 10 (Extra)

has anyone got the code solution to Task 10 of Python Control Flow: Medical Insurance Project?

the instructions are:

  1. Use try and except statements to build error control into your code.
  2. In your analyze_bmi() function, notify the individual how much they need to lower their BMI to bring it to a normal weight range.
  3. Create a new function or code block that utilizes control flow in some way – feel free to experiment!

Please avoid requesting code solutions as per the forum guidelines. Since this a learning environment you’re not getting much out of copy/pasting solutions.

What you should do is attempt the problem and if you should get stuck then you can consider checking the forums. If you need to ask a question that’s not covered elsewhere please check the following FAQ first on how to ask good questions and thereby potentially receive the most helpful answers-


I’m also quite stuck on this try & except assignment. I tried it like the following:

  def analyze_bmi(bmi_value):
    return bmi_value
  if bmi <= 10:
    print("bmi input incorrect")

It does however not print anything. Is it because the try&except statements should be included in another function? If so, how exactly should the statements be denoted? I’m unsure about what statements follow ‘try’ and ‘except’.
Can someone help? :slight_smile: Merci!

It is because there isn’t really any reason for the

def analyze_bmi(bmi_value):
  return bmi_value

to throw an error. Why do you make a function that returns it’s parameter? Do you actually need the try…except here?

Alright, but is there any possibility of getting support to solve this problem? I am trying to find some helpful information on google but it is usually for advanced level coders…

The forums are mainly composed of other learners and you can certainly ask for input here; a new thread under #get-help:python would be the best choice as this thread is old.

As mentioned in the post above (the linked FAQ is an excellent resource) it’s better to actually flesh out an idea before asking questions, a.k.a. try and solve it and come back with what you’ve done and explain what you’re stuck on.

Many folks who answer questions prefer giving hints and pushing you to resolve the issue yourself as it has a tendency to reinforce what you’re learning (getting stuck helps things stick in memory, at least I think it does :slightly_smiling_face:). Cheers.