try: letters = ["a", "b"] print(letters[2]) except IndexError: print("An error has occurred" )