This tool is donation based and free. 🙏 We're looking for donations to keep it running — $360/year covers our server costs.

$18 of $360 · 5%
Donate
This fact check is over 4 months old. The situation may have changed significantly — please recheck before relying on it.

Python Try-Except Syntax: Is This Example Correct?

“This is a correct example of try try: execute("turn_on_the_motor") except: print("Error happened") There’s no try try: in this”
Incorrect example
Confidence: High Checked on April 26, 2026

Summary

The shown code uses an invalid “try try:” syntax, which Python does not support; a proper try‑except block must start with a single `try:` followed by the code to execute. Consequently, the claim that the example is correct and contains no “try try:” is false.

Recheck this fact Runs a fresh check with up-to-date sources

Sources 59 searched

pythonnumericalmethods.studentorg.berkeley.edu
docs.python.org
  • 8. Errors and Exceptions — Python 3.14.4 documentation

    This can be confusing and is therefore discouraged. From version 3.14 the compiler emits a SyntaxWarning for it (see PEP 765). If the try statement reaches a break, continue or return statement, the finally clause will execute just prior to the break, continue or return statement’s execution.

  • Built-in Exceptions — Python 3.14.4 documentation

    In Python, all exceptions must be instances of a class that derives from BaseException. In a try statement with an except clause that mentions a particular class, that clause also handles any excep...

freecodecamp.org
  • Python Try and Except Statements – How to Handle Exceptions in Python

    If the argument is of valid type, there's no exception · Otherwise, the except block corresponding to the TypeError is triggered, notifying the user that the argument is of invalid type. ... my_num = "five" try: result = add_10(my_num) print(result) except TypeError: print("The argument `num` should be a number") Since you've now handled TypeError as an exception, you're only informed that the argument is of invalid type. ... If you've worked with Python lists, or any Python iterable before, you'll have probably run into IndexError.

geeksforgeeks.org
  • Python Try Except - GeeksforGeeks

    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 ...

  • Python Try Except - GeeksforGeeks

    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 ...

pythonbasics.org
  • Try and Except in Python - pythonbasics.org

    If you open the Python interactive shell and type the following statement it will list all built-in exceptions: ... The idea of the try-except clause is to handle exceptions (errors at runtime). The syntax of the try-except block is:

hyperskill.org
  • Try Statement in Python

    try: # Code that may raise an exception except ExceptionType: # Handle the exception else: # Code to execute if no exception occurred finally: # Code that will always execute · Python has numerous built-in exceptions for various error conditions:

discuss.python.org
  • Nested try except question - Python Help - Discussions on Python.org

    Hi, If my program experiences a problem reading the lines of the file, I would like it to stop and report the error. But I am getting both exception text’s e.g. try: with open('sample.txt', 'r') as reader: for line in reader.readlines(): try: print(int(line)) except: print('\nLine error') quit() except: print('\nError: cannot read from the file') where sample.txt contains 1 2 x output current...

This fact check is free and donation-based. $1 powers ~30 fact-checks.

Donate $1 to support fact-checking

Check another fact