I am doing the Problem set 3 :Fuel Gauge. With every other fraction input the program works fine, but when I inputed 10/10, the program will can't detect /
, and so that the program can't split the fraction successfully, the terminal will show not containing /
. I just didn't get it, did I overlook any failure?
import string
def main():
while True:
s = input("Fraction: ")
number = []
if s.find("/") != True:
print("not containing /")
pass
else:
number = s.split('/')
x = number[0]
y = number[1]
if "." in x or "." in y:
pass
elif x.isdigit() != True or y.isdigit() != True :
print("contain . ")
pass
else:
printN(x,y)
break
def printN(x,y):
try:
x_f = float(x)
y_f = float(y)
result = x_f/y_f*100
except (ValueError, ZeroDivisionError):
pass
else:
while True:
if result >= 99:
print("F")
break
elif result <= 1:
print("E")
break
elif result >= 101:
pass
else:
print(round(result),"%",sep='')
break
main()