0

I have the following code:

from fractions import Fraction
p= input("Input the chance of occurrence")
while True:
    try:
        p=float(p)
        break
    except ValueError:
        try:
            p=float(sum(Fraction(s) for s in p.split()))
            break
            
        except:
            print("I don't understand the given input")
            continue

The thing is that when the third case is given, it doesn't ask for another input, instead continues printing "I don't understand the given input", so, how can I prevent this Thanks in advance

Jenifer
  • 75
  • 1
  • 8
  • You need to ask for a new input inside the loop. Your current code is just looping endlessly on the first value. – tripleee Jul 13 '21 at 11:13
  • It is a while loop. Once you provide the input, it is continuing –  Jul 13 '21 at 11:13
  • Now I see, I've modified my code putting the input inside the loop and worked, thanks both of you – Jenifer Jul 13 '21 at 11:44

0 Answers0