Please show your code. But I assume you want to know how to do what you've typed above.
Preferably, you'd want to place the variables in a list of tuples like this:
your_tuple_list_name = [(1, 2.33, 'KG'), (2, 3.0, 'KG'), (3, '(empty)', 'KG'), ('x', 222, 'KG'), ('y', 233.4, 'KG'), ('y', 112, '%'), ('z', 222, 'KG'), ('w', 9.98, 'KG'), ('a', 3224, 'KG'), ('.', '....', '..'), (add other tuples here)]`
If you want to add more items to the list of tuples just add them following the format:
(first_column, second_column, third_column)
And then the method would be like this:
def formatted_printing(your_tuple_list):
space = ' '
for n in range(len(your_tuple_list)):
number = 8 - len(str((your_tuple_list[n][1])))
print("{:>} {:<}{}{:<}".format(your_tuple_list[n][0], your_tuple_list[n][1], (space * number), your_tuple_list[n][2]))
formatted_printing(your_tuple_list_name)
With the following being the output:
1 2.33 KG
2 3.0 KG
3 (empty) KG
x 222 KG
y 233.4 KG
y 112 %
z 222 KG
w 9.98 KG
a 3224 KG
. .... ....