Quiz Catalog

Catalog of quizzes

try:
  raise IndexError
except IndexError:
  print("Получаем исключение")
else:
  print("Ловим его")
Получаем исключение
  • statement/try

def f():
  try: 
    return 1
  finally:
    return 2

print(f())
2
  • statement/try

def foo(value):
  num = 12
  try:
  num //= value
  except:
  num = 3
  else:
  num = 4
  return num

print(foo(4))
4
  • statement/try
  • statement/try/else

try:
  print(1 / 0)
except:
  raise RuntimeError("Something bad happened")
ZeroDivisionError: division by zero
  • statement/raise
  • statement/try