My code contains a regular try-except block. I downloaded the pycodestyle library to test pep8 on my code. I tested my code and I got the following PEP8 error:
E722 do not use bare 'except'
Why does this happen, and how can I fix it? Thanks.
My code contains a regular try-except block. I downloaded the pycodestyle library to test pep8 on my code. I tested my code and I got the following PEP8 error:
E722 do not use bare 'except'
Why does this happen, and how can I fix it? Thanks.
 
    
    You should include a specific exception.
For example,
try:
   <stuff>
except IndexError:
   <stuff>
Instead of
try:
   <stuff>
except:
   <stuff>
It helps with debugging - you'll know if an unexpected error pops up, and the error won't fly by possibly messing something else up.
