Reputation: 968
I would like to know how could I format this string:
"){e<=2}"
This string is inside a function, so I would like to asign the number to a function parameter to change it whenever I want.
I tried:
"){e<={0}}".format(number)
But it is not working, Could anybody give me some advice? Thanks in advance
Upvotes: 1
Views: 61
Reputation: 15
An old-school version for this:
"){e<=%d}" % (number)
'){e<=2}'
Upvotes: 0
Reputation: 1270
Double the braces which do not correspond to the format placeholder...
"){{e<={0}}}".format(number)
You could also use an f-string, if using Python 3.6 or above.
f"){{e<={number}}}"
Upvotes: 1