-1

I'm making a percentage finder, pretty basic. But, I would only like to print 4 characters in the float or int. Can anyone help? Here is my code so far:

    numer = int(input("What's the numerator?"))
    denom = int(input("What's the denominator?"))
    percent = (numer / denom * 100, "%")
    print(percent)

I want the output for 5/6 to be:

    83.33%

But it actually prints:

    83.33333333333334%

1 Answers1

1

you can use % in print function

print("%.2f"%(a/b))
SHIVAM JINDAL
  • 2,844
  • 1
  • 17
  • 34