Use: .format()
:
print("Total score for {0} is {1}".format(name, score))
Or:
// Recommended, more readable code
print("Total score for {n} is {s}".format(n=name, s=score))
Or:
print("Total score for" + name + " is " + score)
Or:
print("Total score for %s is %d" % (name, score))
Or: f-string
formatting from Python 3.6:
print(f'Total score for {name} is {score}')
Can use repr
and automatically the ''
is added:
print("Total score for" + repr(name) + " is " + repr(score))
# or for advanced:
print(f'Total score for {name!r} is {score!r}')