Write a Python Program to Catch Multiple Exceptions in One Line

Python Program to Catch Multiple Exceptions in One Line

Welcome to the World of Online Learning:

Hello Friends “This blog helps you to learn  Python programming concepts. You can learn Python language at your own speed and time. One can learn concepts of Python language by practicing various programs given on various pages of this blog. Enjoy the power of Self-learning using the Internet.”

Python Program to Catch Multiple Exceptions in One Line
Python Program to Catch Multiple Exceptions in One Line

Write a Python Program to Catch Multiple Exceptions in One Line

PROGRAM: Python Program to Catch Multiple Exceptions in One Line

/* Python Program to Catch Multiple Exceptions in One Line */

string = input()

try:
num = int(input())
print(string+num)
except (TypeError, ValueError) as e:
print(e)

Input

a
2

Output

can only concatenate str (not "int") to str

Leave a Reply

Your email address will not be published. Required fields are marked *