F-string usage in a print()
Kevin M. Wilson
kevinmwilson1956 at yahoo.com
Tue May 24 17:14:29 EDT 2022
future_value = 0
for i in range(years):
# for i in range(months):
future_value += monthly_investment
future_value = round(future_value, 2)
# monthly_interest_amount = future_value * monthly_interest_rate
# future_value += monthly_interest_amount
# display the result
print(f"Year = ", years + f"Future value = \n", future_value)When joining a string with a number, use an f-string otherwise, code a str() because a implicit convert of an int to str causes a TypeError!Well...WTF! Am I not using the f-string function correctly...in the above line of code???
Caddy Man
Good sense makes one slow to anger, and it is his glory tooverlook an offense.
Proverbs 19:11
More information about the Python-list
mailing list