Re: F-string usage in a print()

2022-05-24 Thread Cameron Simpson
On 25May2022 00:13, Kevin M. Wilson wrote: >Cameron, I have a misunderstanding here, the 'f-string' is used when >the str() is not...isn't it! No, f-strings (format strings) are just a convenient way to embed values in a string. The result is a string. In days of yore the common formatting

Re: F-string usage in a print()

2022-05-24 Thread Cameron Simpson
On 24May2022 21:14, Kevin M. Wilson wrote: >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 +=

Re: F-string usage in a print()

2022-05-24 Thread Mats Wichmann
On 5/24/22 15:14, Kevin M. Wilson via Python-list wrote: > 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 >#

Re: F-string usage in a print()

2022-05-24 Thread Paul Bryan
Try something like: print(f"Year = {years}, Future value = {future_value}") On Tue, 2022-05-24 at 21:14 +, Kevin M. Wilson via Python-list wrote: > future_value = 0 > for i in range(years): > # for i in range(months): >    future_value += monthly_investment >    future_value =

Re: F-string usage in a print()

2022-05-24 Thread MRAB
On 2022-05-24 22:14, Kevin M. Wilson via Python-list wrote: 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

F-string usage in a print()

2022-05-24 Thread Kevin M. Wilson via Python-list
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