which method is best? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

which method is best?

which 'str+int' printing method is best? print ("sum is: "+str(10)) print ("sum is:",10) print ("sum is: {0}".format (10))

31st Oct 2017, 3:27 AM
Ahmmad Jobayer
Ahmmad Jobayer - avatar
2 Answers
+ 10
I think it's the second one because it's the shortest. Doesn't really matter that much.
31st Oct 2017, 3:32 AM
qwerty
qwerty - avatar
+ 6
All the methods show same thing so it's your choice. If I would write this, then i will use first option as my habit to write this, it seems easy, and here 10 is converted to string and then displayed.
31st Oct 2017, 3:34 AM
Lakshay
Lakshay - avatar