I have some code like:
score = 100
name = 'Alice'
print('Total score for %s is %s', name, score)
I want it to print out Total score for Alice is 100
, but instead I get Total score for %s is %s Alice 100
. How can I get everything to print in the right order with the right formatting?
See also: How can I print multiple things on the same line, one at a time? ; How do I put a variable’s value inside a string (interpolate it into the string)?
%
operator is not used as required). However, the question received a truly excellent top answer that comprehensively shows approaches to the problem, so I ended up selecting this question as a canonical and editing the question title to reflect the breadth that was assumed in the answer. – Dagoba