while True:
fact = input("Fraction: ")
try:
num, denom = fact.split("/")
x = int(num)
y = int(denom)
f = x/y
if f <= 1:
break
except (ValueError, ZeroDivisionError):
pass
p = int(round(f * 100))
if p <= 1:
print('E')
if p >= 99:
print('F')
else:
print(f"{p}%")
If i give 0/4 it gave result “E” and 0%,
but i need only “E” as a result. Help please
I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.