Help with Extra Step in Python Strings: Medical Insurance Project


I succeeded to do the extra steps in this project except for one thing. The challenge is to create an output in this format:

Marina is 27 years old with a BMI of 31.1 and an insurance cost of $7010.0.

The output that I have is in this format:

MARINA ALLISON is 27 years old with a BMI of 31.1 and an insurance cost of $7010.0.

How do I make it so that the sentence includes only the first name in the title case format? Everything I do comes out wrong.

Thanks in advance!

This is the code I have for the last part btw:

for i in range(len(names)): sentence = "{name} is {age} years old with a BMI of {bmi} and an insurance cost of {insurance_cost}." print(sentence.format(name=names[i], age=ages[i], bmi=bmis[i], insurance_cost=insurance_costs[i]))

You probably want to modify the string you’re using to replace your {name} placeholder, e.g. name=first_name_uppercase (where first_name_uppercase is aleady formatted correctly).

Whilst you could do this in the .format() call it’s probably cleaner and easier to do it on the line before you do the formatting. So consider the string you get from name[i], work you out how you’d break it up and change the case. Once you’ve done that then you’ve got the correct string object your actually want to substitute in.