by justin_oaks · 3y ago · 0 comments
who='World'
#1 - string concatenation
'Hello, ' + who + '!'
#2 - % operator
'Hello, %s!' % who
#3 - format() method
'Hello, {}!'.format(who)
#4 - f-strings
f'Hello, {who}!' # In order
'Hello, {}!'.format(who)
# Numbered
'Hello, {0}!'.format(who)
# Named
'Hello, {name}!'.format(name = who)