What's the difference between format() and %s? (python) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What's the difference between format() and %s? (python)

What's the difference between format() and %s? (python)

5th Dec 2018, 5:19 PM
kokito
2 Answers
+ 7
You have to use correct type with '%' '%d' % 'abc' => Error '{}'.format('abc') => 'abc'
5th Dec 2018, 5:59 PM
Mert Yazıcı
Mert Yazıcı - avatar
5th Dec 2018, 6:03 PM
visph
visph - avatar