Python Multiple try-except can handle Multiple exceptions. Just mention the exception names, comma-separated inside parentheses, just after except keyword.
try:
...
except (URLError, ValueError, SocketTimeout):
....
Or
try:
...
except (URLError, ValueError):
...
except SocketTimeout:
...
Multiple try except Python
Simple example code.
s = input()
try:
num = int(input())
print(s + num)
except (TypeError, ValueError) as e:
print(e)
Output:
Do comment if you have any doubts or suggestions on this Python exception-handling topic.
Note: IDE: PyCharm 2021.3.3 (Community Edition)
Windows 10
Python 3.10.1
All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.