Why use the "{0}" .format("something") rather than " %s " % "something" ?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why use the "{0}" .format("something") rather than " %s " % "something" ??

I don't really understand the benefit of "{0} {1} ". format(list1[0], list2[1]), I find the use of %s or %d easier to understand, could someone explain the advantages of using the .format method please? thank you in advance :)

25th Jan 2017, 12:08 AM
Paul Jefferyes
Paul Jefferyes - avatar
1 Answer
+ 6
One advantage of using format is that values to be formatted can be used multiple times and out of order: '{0} {1} {0} that is the question'.format( 'to be', 'or not')
25th Jan 2017, 5:21 AM
Igor B
Igor B - avatar