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
Unlike continue, it does not affect the flow of the loop. my_tuple = (0, 1, 2, 3, 4, 5) for number in range(9999): if number == 3: print("Number equals to 3 (outside of try/except!) - continue.") continue try: if number == 5: print("Number equals to 5 (in try/except!)
🌐
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. You can use the else keyword to define a block of code to be executed if no errors were raised: In this example, the try block does not generate any error:
🌐
Python
mail.python.org › pipermail › tutor › 2005-July › 040116.html
[Tutor] try except continue
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.
🌐
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
🌐
Python documentation
docs.python.org › 3 › tutorial › errors.html
8. Errors and Exceptions — Python 3.14.3 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....
🌐
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.")
🌐
EyeHunts
tutorial.eyehunts.com › home › python try except continue
Python try except continue
December 20, 2022 - Then if an error is raised, it will continue with the next file. for infile in listing: try: if infile.startswith("ABC"): fo = open(infile,"r") for line in fo: if line.startswith("REVIEW"): print infile fo.close() except: pass · Source: https://stackoverflow.com/questions/18994334 · Answer: The standard “nop” in Python is the pass statement, Use this code.
Find elsewhere
🌐
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?

🌐
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!") while num_of_guess < 4: try: guess = int(input("Pick an integer between 1 & 10: ")) if guess < 1 or 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()
🌐
Runestone Academy
runestone.academy › ns › books › published › fopp › Exceptions › intro-exceptions.html
19.1. What is an exception? — Foundations of Python Programming
The exception code can access a variable that contains information about exactly what the error was. Thus, for example, in the except clause you could print out the information that would normally be printed as an error message but continue on with execution of the rest of the program.
🌐
Python.org
discuss.python.org › python help
Infinte while loop using try/except - Python Help - Discussions on Python.org
June 15, 2024 - hey y’all! I’m taking an online class called Cs50P, I thought I practiced using while 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.
🌐
TechBeamers
techbeamers.com › use-try-except-python
Try-Except in Python: The Beginner’s Guide - TechBeamers
November 30, 2025 - The first of them requires placing all the exceptions that are likely to occur in the form of a tuple. Please see below. try: file = open('input-file', 'open mode') except (IOError, EOFError) as e: print("Testing multiple exceptions.
🌐
Matt Might
matt.might.net › articles › implementing-exceptions
You don't understand exceptions, but you should
Take the general while loop form in Python for example: ... (call/ec (λ (break) (letrec ([loop (λ () (when cond (call/ec (λ (continue) body)) (loop)))]) (loop) otherwise))) A call to break bails out of the loop, skipping over the else case. A call to continue jumps to the next iteration ...
🌐
Python Guides
pythonguides.com › python-while-loop-continue
Handle A Python Exception Within While A Loop
August 14, 2025 - In this article, I’ll share four proven methods I use to handle exceptions in while loops, complete with real-world examples that you can implement immediately. ... 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 ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-try-except
Python Try Except - GeeksforGeeks
July 23, 2025 - try: # Some Code except: # Executed if error in the # try block else: # execute if no exception finally: # Some code .....(always executed) ... # Python program to demonstrate finally # No exception Exception raised in try block try: k = 5//0 ...
🌐
Blogger
umar-yusuf.blogspot.com › 2017 › 04 › python-break-continue-and-pass-within.html
Geospatial Solutions Expert: Python break, continue and pass within Try... Except block
Sample Code for letter in 'Python': if letter == 'h': break # continue pass print ('Current Letter :', letter) Testing the above code for: break, continue and pass will yield different results as seen below:- If we introduce a "Try ...
🌐
Python Basics
pythonbasics.org › try-except
Try and Except in Python - Python Tutorial
This prevents abrupt exits of the program on error. In the example below we purposely raise an exception. After the except block, the program continues. Without a try-except block, the last line wouldn’t be reached as the program would crash. $ python3 example.py Divided by zero Should reach here
🌐
Server Academy
serveracademy.com › blog › python-try-except
Python Try Except - Server Academy
This is helpful when you want to perform certain actions only when the code in the try block is successful. try: number = int("42") except ValueError: print("Conversion failed!") else: print("Conversion successful:", number) ...