Get Unlimited Contributor Access to the all ExamTopics Exams!
Take advantage of PDF Files for 1000+ Exams along with community discussions and pass IT Certification Exams Easily.
If you need to serve two different exceptions called Ex1 and Ex2 in one except branch, you can write:
a. except Ex1 Ex2:
b. except (Ex1, Ex2):
c. except Ex1, Ex2:
d. except Ex1 + Ex2:
# Answer is B. Point of Q is, you need to use () with except when more than 1.
try:
# TypeError: can only concatenate str (not "int") to str
print( 'five' + 1 )
# ZeroDivisionError: division by zero
print ( 5 / 0)
except (TypeError, ZeroDivisionError):
print('An error occured.')
B should be the answer, but aren't the Exception name case sensitive? In which case, B is not the answer.
upvoted 2 times
...
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
kauser
Highly Voted 3 years, 8 months agoseaverick
Most Recent 2 months, 3 weeks agomacxsz
1 year, 11 months agorocky48
2 years agotechnoguy
2 years, 4 months agoDKM
2 years, 5 months agorbishun
2 years, 5 months agotanst
2 years, 6 months agoBrodeh
3 years, 1 month agoFulano_de_tal
3 years, 1 month agoleonardodicaprio
2 years, 10 months agoBenKa
3 years, 8 months ago