0

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%
0

1 Answer 1

1

you can use % in print function

print("%.2f"%(a/b))
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! It worked!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.