print(f"name = ", i + f"Yearly value = \n", yearly_value)

Why is there an implicit CR + LF w/o placing a '\n' in a print statement, and why can't I attach/assign an in 'int' to a string in a print statement???

File "C:/Users/kevin/PycharmProjects/Myfuturevalue/FutureValueCal.py", line 30, in <module>
    print(f"Year = ", years + f"Yearly value = \n", yearly_value)
TypeError: unsupported operand type(s) for +: 'int' and 'str'
python-BaseException

30: 

print(f"Year = ", years + f"Yearly value = \n", yearly_value)
1 comment
Comment actions Permalink

This is an incorrect usage of f-strings. Perhaps you mean something like this:

print(f"Year = {years}, Yearly value = {yearly_value}")
0

Please sign in to leave a comment.