Hey guys, in this blog we will see a Python Program to Catch Multiple Exceptions in One Line.
Multiple exceptions as a parenthesized tuple
string = input()
try:
num = int(input())
print(string+num)
except (TypeError, ValueError) as e:
print(e)
Input 1
a 2
Output 1
can only concatenate str (not "int") to str
Input 2
a b
Output 2
invalid literal for int() with base 10: 'b'
- We have used try/except in this example.
- It will first try to run the try part and will see if it runs successfully.
- But if it throws any error, it will go in except part and there we have printed the Exception as e.
- The exception can be of any type of 2 we have provided; TypeError or ValueError.
Check out our other python programming examples…


![[Latest] Python for Loops with Examples – Easiest Tutorial – 2025](https://machinelearningprojects.net/wp-content/uploads/2023/05/python-for-loops-1-1024x536.webp)


