While reading a list 'lst', I want to remove an delement that does not meet certain condition. Based on the following answer: Strange result when removing item from a list while iterating over it I found a solution that works great. Here is the code in PyCharm:
for ind, el in enumerate(lst):
if not el.strip() or el.strip() != 'LABEL':
lst[ind] = None # here I get a warning concerning ind
else:
break
lst = [n for n in lst if n is not None]
I cannot figure out why I receive this warning:
Unexpected type(s): (int, None) Possible type(s): (SupportsIndex, str) (slice, Iterable[str])
Inspection info:
Reports type errors in function call expressions, targets, and return values. In a dynamically typed language, this is possible in a limited number of cases.
Types of function parameters can be specified in docstrings or in Python 3 function annotations.