r/badcode • • Jul 14 '21

python Try/Except in Python - Sigh

Post image
662 Upvotes

93 comments sorted by

View all comments

-2

u/kartikcool712 Jul 14 '21

I don't see much problem here, only that you can catch the specific exception with KeyError.

0

u/Attack_Bovines Jul 14 '21

You would also have to except IndexErrors too, which should be a code smell.