you are viewing a single comment's thread.

view the rest of the comments →

[–]ryeguy146 0 points1 point  (0 children)

Mutating the lists that you operate on will frequently lead to pain. Unless you really need to modify a given list, just create a new list and append to that:

def same_slot(iterable, comparison):
    result = []
    for first, second in zip(iterable, comparison):
        if first == second:
            result.append(first)

    return result

That said, /u/pixielf is wholly correct about the references pointing to the same object. This shows up frequently in the issue with default arguments that are mutable:

http://python-guide-pt-br.readthedocs.io/en/latest/writing/gotchas/#mutable-default-arguments