Python Classes: Medical Insurance Project

Do you have a question about this code, or just sharing a project?

Hi 8-bit-gaming,
It was meant for sharing.
Thank you for asking!

1 Like

I have a question about this project. There are a lot of people using .format to add curly brackets to the print texts. This is not part of the Classes lesson but whatever .format does, it appears often without explanation. None of the hints, in fact, recommend the use of the .format from what I can see. Instead they will say something like:

print( + " is now " + str(self.age) + " years old.")

Which is a preferable way to put this in the print function? If it is format, I really wish that would have been taught. Either the postings here are copies of one another or they are using a different pathway to get to this project. The DS path has not taught .format up to Classes (thus far) and only introduces it without explanation in the section.

Hello! You can use concatenation, but .format() would be preferable (it is just more readable). Personally, I prefer to use Python’s f-string:

some_variable = 10
print(f"The number stored in some_variable is {some_variable}")
#the f at the beginning of the string tells Python that you're using an f-
#string. You then place the variable name between the curly braces.

Here is an article on the two methods, as well as some other methods.
I hope this helps!


Ok. Thank you. This is helpful. I think this print(f"") version of .format was introduced a few months ago (from my memory of progress) but I have not used it since.

1 Like