Good, so these are actually two questions. First, I want to know if there is a way to check if the list index exists. For example, I want to increase the list [i] every time this condition is true, using a type code list[i] += 1, but if the index does not exist, I get an error. So I want to set up a test that, in case of an error, does something like list.append(1). What code can fulfill such a test condition? If list[i]gives an error message.
As a follow-up question, once the test is installed, is there a way to create a list index other than using the above add method?
source
share