0
How do you concatenate string with float? If not, how do you print the interest amt. beside the sentence 'rate of int is' ?
4 Respuestas
+ 3
Some other ways you can do the same with python:
print('rate of interest is ' + str(i))
print('rate of interest is {}'.format(i))
print(f'rate of interest is {i}')
The last trick is called string interpolation, also known as f-string in python, and my personal favorite method.
+ 2
You can just include i in the print() call: (you don't need to convert numbers to strings in this case)
print('rate of interest is: ',i)
+ 2
Thanks for the info! I'm still learning but I'll try my best to make the code as efficient as possible!
+ 1
Thank you. I recently started python. I used JavaScript before that so I was trying print('rate of int is: ' + i).