0

How do you concatenate string with float? If not, how do you print the interest amt. beside the sentence 'rate of int is' ?

https://code.sololearn.com/cvMU59k38hMe/?ref=app

11th Feb 2020, 2:33 PM
sTiNgRaY
sTiNgRaY - avatar
4 Respostas
+ 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.
11th Feb 2020, 7:11 PM
Tibor Santa
Tibor Santa - avatar
+ 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)
11th Feb 2020, 2:39 PM
Lothar
Lothar - avatar
+ 2
Thanks for the info! I'm still learning but I'll try my best to make the code as efficient as possible!
11th Feb 2020, 7:14 PM
sTiNgRaY
sTiNgRaY - avatar
+ 1
Thank you. I recently started python. I used JavaScript before that so I was trying print('rate of int is: ' + i).
11th Feb 2020, 2:40 PM
sTiNgRaY
sTiNgRaY - avatar