Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
def do_stuff_with_number(n):
     print(n)

def catch_this():
     the_list = (1, 2, 3, 4, 5)

     for i in range(20):
           try:
                 do_stuff_with_number(the_list[i])
           except IndexError: # Raised when accessing a non-existing index of a list
                 do_stuff_with_number(0'out of bound - %d' % i)

catch_this()