I tried to remove space but it is not giving me the desired output.output that I want without using space in f string
Asked
Active
Viewed 31 times
-1
-
Dont use images. Put code as text in question. – Albin Paul Jan 14 '23 at 07:17
-
https://stackoverflow.com/questions/12684368/how-to-left-align-a-fixed-width-string this might be helpful. – Albin Paul Jan 14 '23 at 07:21
-
Use wizard for your first question – willwrighteng Jan 14 '23 at 09:08
1 Answers
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