I am looking for a simple, pythonic way of doing this with the minimum calculations and loops.
I have a bunch of strings, such as:
1 + 2 = 3
2*6 + 13 = 25
What I would like to print at the screen is:
xxx1 + 2 = 3
2*6 + 13 = 25
(where the x
are actually spaces, but I could not figure out how to show it with this editor)
I am aware of string formatting with left and right align but this imply for each string to compute the number of spaces to add, convert it into a string, and inject this into the string alignment formatter, which seems complex.
Is there a simpler way?