-2

If there are more than one except: branches after the try:, can we say that:

  • one or more of the try: blocks will be executed
  • none of the try: blocks will be executed
  • not more than one try: block will be executed
  • exactly one of the try: blocks will be executed

In my opinion, the right answer will be "not more than one try:", but maybe "one or more of the try:"?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
  • Where you've written "`try:` blocks", did you mean "`except:` blocks"? You can only have one `try:` block per statement, whereas it can have zero (if there's a `finally:` block), one or many `except:` blocks. – jonrsharpe Jan 20 '21 at 17:08
  • Exactly one `try` block will be executed, and zero or one `except` block, and zero or one `else` block if present, and exactly one `finally` block if present. – deceze Jan 20 '21 at 17:09
  • Thanks a lot, all clear ;) – Mikołaj Kabała Jan 20 '21 at 17:09

1 Answers1

0

It will show an error like this:

SyntaxError: default 'except:' must be last

You can either run this code:

try:
   something...
except:
   something...
finally:
   something...