python-novice-inflammation icon indicating copy to clipboard operation
python-novice-inflammation copied to clipboard

Use f-strings

Open airalcorn2 opened this issue 3 years ago • 1 comments

I think the lesson would benefit from switching to f-strings for print statements. E.g., the line here:

print('weight in pounds:', 2.2 * weight_kg)

would become:

print(f'weight in pounds: {2.2 * weight_kg}')

f-strings are typically more readable and easier to work with than other printing options.

airalcorn2 avatar Nov 01 '22 15:11 airalcorn2

I agree that they are more readable. Might it be best to demonstrate all ways of formatting a string and highlighting the pros and cons of each method? I'm thinking that if a learner comes across some code using one of the older formatting methods they might not understand what that method is doing.

tintin554 avatar Mar 31 '23 13:03 tintin554