I am trying to make a simple program in python and I want to display my output in a simple tabular format. But the alignment is getting disturbed every time. The constraint is not to use format()
of Python.
I am trying to print required output using string format in python. But I am unable to get the required output. Please help me.
I have tried this :
def footToMeter(foot):
Meter = 0.305 * foot
return Meter
def meterToFoot(meter):
Foot = meter / 0.305
return Foot
i = 1.0
j = 20.0
header = ('Feet','Meters | ','Meters','Feet')
print("%-14s%-15s%-15s%-15s" % header)
while i<=15:
print("%s" % i ,"%15.3f" % footToMeter(i)," | ",j,"%16.3f" %
meterToFoot(j))
i = i + 1
j = j + 6
Actual output should be in perfectly left aligned tabular format ( check below output ) . But alignment of my output is slightly disturbed.