What Will Be The Output Of The Following Python Code If The #1159
What will be the output of the following Python code if the input entered is 6?</p> <pre><code class="language-python">valid = False while not valid: try: n=int(input("Enter a number")) while n%2==0: print("Bye") valid = True except ValueError: print("Invalid")</code></pre>
This multiple choice question (MCQ) is related to the book/course gs gs109 Python. It can also be found in gs gs109 Exception Handling - Python Exception Handling - Quiz No.1.
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")
Bye (printed once)
No output
Invalid (printed once)
Bye (printed infinite number of times)