Python arithmetic formatter - string format issues

I am trying to format each calculation using new list i.e regex_split. format seems to work when I use i substitute 1 in for 0 so I am not sure why it doesn’t work for the first list item.

 if len(regex_split[0]) > len(regex_split[-1]):

        regex_split[0] = f'{regex_split[0]:>2}'
        regex_split[2] = f'{regex_split[2]:>{len(regex_split[0])}}

Could you say something more? What do you expect to happen, what is happening instead? Some examples when it works and not?

Trying to add spaces next to the numbers in the array:

[’ 32’, ‘-’, ’ 698’] - do all of that to get final result looking similar to these calculations below

image

But what is regex_split? How is it used later? You have mentioned it works sometimes, for what cases it does? For what it doesn’t? Without more context what pasted code should be doing, and how that fits into the rest of code, it may be hard if not impossible to help.

regit _split is a list made up of the pieces that make up a calculation. eg 32 + 698 becomes regex_split = [‘32’, ‘+’, ‘698’]. I then try to edit each item to add the spaces required to look like the image above.

image