Examveda

What will be the output of the following Python code if the input entered is 6?
valid = False
while not valid:
    try:
        n=int(input("Enter a number"))
        while n%2==0:
            print("Bye")
        valid = True
    except ValueError:
        print("Invalid")

A. Bye (printed once)

B. No output

C. Invalid (printed once)

D. Bye (printed infinite number of times)

Answer: Option D


This Question Belongs to Python Program >> Exception Handling In Python

Join The Discussion

Related Questions on Exception Handling in Python