Question discussion

What is the output of the following Python code?try: int("x") except ValueError: print("V", end=" ") else: print("E", end=" ") finally: pri…

2122Medium DSSSB TGT Computer Science 0 replies 1 views
0

What is the output of the following Python code?

try:
    int("x")
except ValueError:
    print("V", end=" ")
else:
    print("E", end=" ")
finally:
    print("F")
  • AV E F
  • BV F
  • CE F
  • DF
Correct answer: B

Explanation

int("x") raises ValueError, so the except block prints V, the else block is skipped and the finally block always runs and prints F.

Discussion 0

Nobody has replied yet. Start the discussion!