Search code examples
pythonoutputwhitespacesymbolspercentage

How do I add a percentage symbol at the emd of my output with no whitespace?


My output on an assignment is correct except for the whitespace at the end of my output before the percent symbol.

My output :

Your final grade is 86.75 %

Expected output (zybooks):

Your final grade is 86.75%

What I have in my program:

print(f'Your final grade is',final_grade,'%')

Solution

  • You can make use of f-strings more effectively when you do: print(f'Your final grade is {final_grade}%')

    You can read more about it here: https://realpython.com/python-f-strings/