Try Except#

Part 1#

What is the output of the following code?

try:
    print("hi!")
    num = '{{ params_vars_num }}'
    if num % 3 != 0 :
        print("nope")
    else:
        print("yep")
except:
    print("huh?")
finally:
    print("ok")

Answer Section#

  • Prints three lines: hi! huh? ok

  • Prints two lines: huh? ok

  • Prints three lines: hi! nope huh?

  • Prints two lines: hi! huh?

Attribution#

Problem is licensed under the CC-BY-NC-SA 4.0 license.
The Creative Commons 4.0 license requiring attribution-BY, non-commercial-NC, and share-alike-SA license.