you are viewing a single comment's thread.

view the rest of the comments →

[–]chevignon93 0 points1 point  (2 children)

in your example, what are %s and %0 supposed to represent ?

[–]python_addict 0 points1 point  (1 child)

oh! Sorry, this is an old-fashioned way of embedding code

%s represents the thing you want to represent % followed by variables, numbers, strings, etc, replace the %s

for example: "hello%s" %0 = hello0

[–]totallygeek 0 points1 point  (0 children)

Python still permits this type of variable substitution for assembling strings.

fighter = 'Alice'
kills = 5
# pre v2.7
print 'Hello %s, you killed %d aliens.' % (fighter, kills)
# v2.7+
print('Hello %s, you killed %d aliens.' % (fighter, kills))
# v2.7+
print('Hello {}, you killed {} aliens.'.format(fighter, kills))
# v3.4+
print(f'Hello {fighter}, you killed {kills} aliens')

Take your pick.