# String with numbers output formating [closed]

Is there something similar to print("blah blah is %d", 5) in python? In order to print "blah blah is 5"?

• Print["blah blah is ", 5]? – MassDefect May 11 '19 at 0:24
• Wait, why is this off topic? – Ion Sme May 15 '19 at 3:28
• In python doing comma splicing is seen as bad practice, so wanted to avoid Print["blah blah is ", 5] That's why I asked the question. – Ion Sme May 15 '19 at 3:42

You can use StringForm:

StringForm["blah blah is 1 and other blah is 2", 5, 10]


blah blah is 5 and other blah is 10

There's also StringTemplate:

StringTemplate["blah blah blah is first"][<|"first"->1|>]

blah blah blah is 1


which has the advantage that you can assign your template and easily call it frequently (here, I'm using a simpler form than above):

template = StringTemplate["blah blah blah is "]

Map[template, {1,2,3,4}]

{"blah blah blah is 1", "blah blah blah is 2", "blah blah blah is 3", "blah blah blah is 4"}


You might then use Print or Echo or similar functions to actually "print" your statements, but this isn't a common paradigm in Wolfram Language.

• I don't like StringTemplate because of things like: StringTemplate["blah blah blah is first"][<|"first"->1/2|>]. – Carl Woll May 11 '19 at 22:28
• @CarlWoll What behaviour would you prefer? I feel as though in python, print('x, y, %d', 1/2) would also print 'x, y, 0.5'... But in any case, I only wanted to add it as an option here. StringForm is probably closer to what the user wanted :) – Carl Lange May 12 '19 at 6:51