How to quickly figure out which list is causing the error?
In a python script, if we have multiple lists in a single expression, for example:
a[1] = b[2] + c[3] + d[4]
OR
a[1] = b[c[d[1]]] # (This case added in EDIT)
Now, one of these lists throws an error IndexError: List Index Out of Range because the index is higher than the list length.
Is there a way to improve this default exception handling using try/except statements such that we can instantly figure out which list caused the problem?
Otherwise, one needs to check each list using a command line debugger. I understand that if an IDE is available, then this feature is probably inbuilt into the IDE.
from Recent Questions - Stack Overflow https://ift.tt/3DWJn08
https://ift.tt/eA8V8J
Comments
Post a Comment