I’m trying to catch multiple exceptions in one line using the except
block in Python. I’ve tried using commas to separate the exceptions, but I’m getting a syntax error. Can someone please show me how to catch multiple exceptions in one line?
Here’s the code I’ve tried so far:
try:
print(int('5.5'))
except ValueError, TypeError:
print(error)
This code is giving me a syntax error on the except
line. Can someone please show me how to correctly catch multiple exceptions in one line using the except
block in Python?
Thank you.