Home » Programming Language (coding) » Python MCQs » What is the output of the following? try: if ‘1’ != 1: raise “someError” else: print(“someError has not occurred”) except “someError”: print (“someError has occurred”)

What is the output of the following? try: if ‘1’ != 1: raise “someError” else: print(“someError has not occurred”) except “someError”: print (“someError has occurred”)

What is the output of the following?

try:
    if '1' != 1:
        raise "someError"
    else:
        print("someError has not occurred")
except "someError":
    print ("someError has occurred")

A. someError has occured
B. someError has not occured
C. invalid code
D. none of the mentioned

Answer: C. invalid code

Take Part in Discussion:

Your email address will not be published.

Solve : *
16 + 30 =