-1

code that I am writing

I tried to remove space but it is not giving me the desired output.output that I want without using space in f string

Dany
  • 1
  • 1

1 Answers1

1

It is unclear what you mean when you say that you don't want to use a space in an f-string, however, that is exactly how I was able to align the column headers with the results. Note: you may also want to consider using a pandas dataframe.

Code:

x=(6/7) * 100
y=(4/7) * 100

print ('1234567890123456789012345')
print(f'Course Grade Percentage')
print(f'ITC    A     {x}')
print(f'maths  B     {y}')

Output:

1234567890123456789012345
Course Grade Percentage
ITC    A     85.71428571428571
maths  B     57.14285714285714
ScottC
  • 3,941
  • 1
  • 6
  • 20