Error prone sequence modification
The iterable object for the loop expression is calculated once and remains unchanged despite any index changes caused by the sequence modification. This might lead to unexpected bugs. If you need to modify the sequence, we recommend that you first make a copy, such as by using slice notation.
def modifying_list_noncompliant():
    words = ['cat', 'window', 'defenestrate']
    # Noncompliant: modifies the same list while iterating over it.
    for word in words:
        if len(word) > 6:
            words.insert(0, word)
def modifying_list_splice_compliant():
    words = ['cat', 'window', 'defenestrate']
    # Compliant: creates new list using splicing, hence loops iterate on one
    # list, modifying a different list.
    for word in words[:]:
        if len(word) > 6:
            words.insert(0, word)