No, you cannot do that. That's just the way Python has its syntax. Once you exit a try-block because of an exception, there is no way back in.

What about a for-loop though?

funcs = do_smth1, do_smth2

for func in funcs:
    try:
        func()
    except Exception:
        pass  # or you could use 'continue'

Note however that it is considered a bad practice to have a bare except. You should catch for a specific exception instead. I captured for Exception because that's as good as I can do without knowing what exceptions the methods might throw.

Answer from user2555451 on Stack Overflow
🌐
Devcuriosity
devcuriosity.com › manual › details › python-try-except-finally-continue-break-loops
Python - Try, Except, Finally, Continue, Break in Loop Control Flow with examples
except - Catch exception after try, be sure to add specific error that you want to catch. eq. TypeError · continue - Immediately go to the next loop iteration, skipping any remaining code in the current iteration.
Discussions

How to put continue operator of a loop into an except block
You have to put the error handling inside the loop: while True: try: # etc except: continue More on reddit.com
🌐 r/learnpython
12
5
August 2, 2023
How to continue loop after exception?
Having some issues with my code. Once it raises the ValueError, the program stops. Where I have the "#continue" located is where I thought I had to put the continue for it to run, but that didn't work either. ... Put your try/except inside the while loop. More on teamtreehouse.com
🌐 teamtreehouse.com
1
December 28, 2020
Does a try/except block continue the try block after catching an exception?
No, the execution in the try block doesn't continue. If you think about it, how would that work - in general I mean? An exception is thrown because something has gone wrong that can't be dealt with by the immediate code. You are therefore not in a fit state to execute the lines of code that follow the exception throwing line as in general they are going to depend on previous lines having executed correctly. If you are able to handle an exception in such a way that the following code can execute, then it is up to you to write the code in such a way that that can happen. In particular you need to narrow the scope of your try - except block. More on reddit.com
🌐 r/learnpython
7
1
October 2, 2024
Infinte while loop using try/except
I’m taking an online class called ... loops + try/exceptions to the point of being confident using this structure. I’m running into an infinite loop when the exceptions are raised in the convert() function. I just don’t understand why. In both exceptions the “continue” statement ... More on discuss.python.org
🌐 discuss.python.org
5
0
June 15, 2024
🌐
Python documentation
docs.python.org › 3 › tutorial › errors.html
8. Errors and Exceptions — Python 3.14.5rc1 documentation
If an exception occurs during execution ... is skipped. Then, if its type matches the exception named after the except keyword, the except clause is executed, and then execution continues after the try/except block....
🌐
W3Schools
w3schools.com › python › python_try_except.asp
Python Try Except
try: print(x) except NameError: print("Variable x is not defined") except: print("Something else went wrong") Try it Yourself » · See more Error types in our Python Built-in Exceptions Reference.
🌐
Reddit
reddit.com › r/learnpython › how to put continue operator of a loop into an except block
r/learnpython on Reddit: How to put continue operator of a loop into an except block
August 2, 2023 -

I want the loop to skip to the next iteration when ValueError is raised. Raising error there is a must. I try to put continue operator in except block but it's wrong. Please help me, thanks

NList = []
def isInt(N):
    try:
        int(N)
        return True
    except:
        return False

try:
    while True:
        N = input("Enter an positive interger: ")
        if N == 0: break
        NList.append(N)
        if not isInt(N):
            raise ValueError("It's not an interger")

        int(N)    
        if N < 1:
            raise ValueError("It's not positive")

except ValueError as e:
    print(e)
    continue
🌐
Team Treehouse
teamtreehouse.com › community › how-to-continue-loop-after-exception
How to continue loop after exception? (Example) | Treehouse Community
December 28, 2020 - \n If you can\'t correctly guess my number within 3 tries, it\'s GAMEOVER!") try: while num_of_guess < 4: guess = int(input("Pick an integer between 1 & 10: ")) if 1 < guess > 10: raise ValueError #continue if guess == answer: print("Congrats! You guessed my number") else: if guess > answer: print('Too High') else: print("Too Low") num_of_guess += 1 except ValueError as err: print(("Number has to be integer between 1 & 10, try again!")) start_game()
🌐
GeeksforGeeks
geeksforgeeks.org › python › try-except-else-and-finally-in-python
Try, Except, else and Finally in Python - GeeksforGeeks
The code enters the else block only if the try clause does not raise an exception. Example: Else block will execute only when no exception occurs. ... # Python code to illustrate working of try() def divide(x, y): try: # Floor Division : Gives only Fractional # Part as Answer result = x // y except ZeroDivisionError: print("Sorry !
Published   July 15, 2025
Find elsewhere
🌐
Real Python
realpython.com › python-exceptions
Python Exceptions: An Introduction – Real Python
December 1, 2024 - When an exception occurs in a program that runs this function, then the program will continue as well as inform you about the fact that the function call wasn’t successful. What you didn’t get to see was the type of error that Python raised as a result of the function call. In order to see exactly what went wrong, you’d need to catch the error that the function raised. The following code is an example where you capture the RuntimeError and output that message to your screen: ... # ... try: linux_interaction() except RuntimeError as error: print(error) print("The linux_interaction() function wasn't executed.")
🌐
Reddit
reddit.com › r/learnpython › does a try/except block continue the try block after catching an exception?
r/learnpython on Reddit: Does a try/except block continue the try block after catching an exception?
October 2, 2024 -

I have a function that loops over a list of IDs and makes an API query for each ID in the list. This list is 600ish IDs long. Occasionally I run into the issue where my API token will expire before the function completes. In another post I believe i addressed that issue by creating a function that should ensure my API token doesnt expire. What I have is this:

def query_form_dynamic_data(oauth, token) -> list:
    # Loop through the list of form IDs and pass the ID as a variable to the GraphQL query

    form_id_list = query_pif_id(oauth, token)
    dynamic_data = []

    try:
        token = ensure_token(oauth, token)
        transport = create_transport_protocol(token, proxies)
        client = create_graphql_client(transport)

        for key, val in enumerate(form_id_list):
            query = gql(""" query goes here """)

            result = client.execute(query, variable_values=val)
            result = result["documents"]

            dynamic_data.append(result)

    except TokenExpiredError as err:
        token = ensure_token(oauth, token)

    return dynamic_data

What im hoping this does is by calling my ensure_token function before the query, if the token has expired, it would refresh the token. But if it expires in the middle of my loop then im screwed. I know it throws the TokenExpiredError if that happens and then it'll rerun my ensure_token function to get a new key, but will the contents of my try block continue at that point?

🌐
Python.org
discuss.python.org › python help
Infinte while loop using try/except - Python Help - Discussions on Python.org
June 15, 2024 - I’m taking an online class called ... loops + try/exceptions to the point of being confident using this structure. I’m running into an infinite loop when the exceptions are raised in the convert() function. I just don’t understand why. In both exceptions the “continue” statement ...
🌐
Runestone Academy
runestone.academy › ns › books › published › fopp › Exceptions › intro-exceptions.html
19.1. What is an exception? — Foundations of Python Programming
You have to make some change in your code and rerun the whole program. ... Try to execute a block of code, the “try” clause. If the whole block of code executes without any run-time errors, just carry on with the rest of the program after the try/except statement.
🌐
Python
mail.python.org › pipermail › tutor › 2005-July › 040116.html
[Tutor] try except continue
September 14, 2013 - Consider: error = True def f(): if error: raise ValueError else: print 'In f()' def g(): print 'In g()' while True: try: f() g() except ValueError: error = False continue continue will cause the *next* iteration of the loop to start.
🌐
Astral
docs.astral.sh › ruff › rules › try-except-continue
try-except-continue (S112) | Ruff
import logging while predicate: try: ... except Exception: continue · Use instead: import logging while predicate: try: ... except Exception as exc: logging.exception("Error occurred") lint.flake8-bandit.check-typed-exception · Common Weakness Enumeration: CWE-703 · Python documentation: logging Back to top
🌐
Python.org
discuss.python.org › python help
Why aren't exceptions re-raised if `finally` contains a `return/break/continue`? - Python Help - Discussions on Python.org
August 11, 2022 - From the docs: If the finally clause executes a break, continue or return statement, exceptions are not re-raised. Why is this? I would have thought that an exception would take priority over a return/break/continue statement, especially since ...
🌐
Python Guides
pythonguides.com › python-while-loop-continue
Handle A Python Exception Within While A Loop
August 14, 2025 - The simplest way to handle exceptions in a while loop is to wrap your code in a try-except block. This prevents the loop from terminating when an error occurs. I use this method when I want the loop to continue running regardless of errors.
🌐
Quora
quora.com › How-do-you-continue-execution-after-exception-in-Python
How to continue execution after exception in Python - Quora
The Interpreter tracks the call stack anyways. It has to clean up finished stacks no matter what. You can just as well use that for your own advantage. ... By design, exceptions default to being handled whereas return values default to being unhandled. Consider naively looking up a value from a mapping: ... Since a dict in Python raises KeyError on missing keys, this error cannot go unnoticed.
🌐
Real Python
realpython.com › python-continue
Skip Ahead in Loops With Python's continue Keyword – Real Python
March 27, 2025 - In other words, a continue statement in a try-except block will not prevent any code in an associated finally block from being executed, even if continuing the loop transfers control out of a try or except block.
🌐
Learn By Example
learnbyexample.org › python-continue-statement
Python Continue Statement - Learn By Example
April 20, 2020 - # in a for Statement for x in range(2): try: print('trying...') continue print('still trying...') except: print('Something went wrong.') finally: print('Done!') print('Loop ended.') # Prints trying...
🌐
Codingem
codingem.com › home › python ‘continue’ statement—a complete guide (with examples)
Python 'continue' Statement—A Complete Guide (with Examples)
July 10, 2025 - If you need to handle exceptions in a loop, use the continue statement to skip the “rest of the loop”. For example, take a look at this piece of code that handles errors in a loop: for number in [1, 2, 3]: try: print(x) except: print("Exception ...
🌐
TutorialsPoint
tutorialspoint.com › How-to-ignore-an-exception-and-proceed-in-Python
How to ignore an exception and proceed in Python?
May 14, 2025 - try: "hello".some_undefined_method() except AttributeError: pass print("Program continues despite AttributeError.")