What are all types of errors in Python?

What are all types of errors in Python?
Today used try/except command, but I did´n know all types of errors that user will can do.

Hi @text2552910116

You can find a list of all the built-in exception types that Python might raise in the documentation, which is here.

Of course, you won’t need all of them every time you create a try ... except structure - you would only need to catch the relevant exceptions. For example, say you’re asking the user for an int and they give you a string - you could catch the TypeError and inform the user their input was invalid.

You can also use except: on its own, without specifying an exception type, if you want a “fall back” position. Like so:

def spam():
        a = 5
        b = "eggs"

        c = a + b # we can't add a string to an integer, so we'll cause a TypeError here.
    except:   # no exception type is specified, so we'll catch any exception that occurs!
        print("Whoops! An exception flew by!")
        raise # the "raise" keyword re-raises the exception that was caught here.
# now run the broken function.

The output we get is:

Whoops! An exception flew by!
Traceback (most recent call last):
  File "spam.py", line 12, in <module>
  File "spam.py", line 6, in spam
    c = a + b
TypeError: unsupported operand type(s) for +: 'int' and 'str'