-1

I want to have output with the same spacing. Let me illustrate desired output:

Item1 = 1000 USD
Item2 = 500  USD
Item3 = 1500 USD

My current code:

print("{:4s} = {} {}" .format(name, round(value), currency))

My current output has very ugly second item output

Item1 = 1000 USD
Item2 = 500 USD
Item3 = 1500 USD

The problem is that for the second variable I cannot fix the spacing it consumes unlike the string in first variable.

Alphatio
  • 47
  • 5

1 Answers1

0

Thank you for all your suggestion. My final code is below - work as expected.

print(f"{asset_name:<6}" + ' = ' + f"{round(asset_value,2):<7}" + '  ' + f"{qoute_currency:<3}")
Alphatio
  • 47
  • 5