Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed: KeyError caused due to the same element getting removed from a set twice #216

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Commits on Oct 12, 2024

  1. Fixed: KeyError caused due to the same element getting removed from a…

    … set twice
    
    for item_a in set_a:
        for item_b in set_b:
            if <some condition:True>:
                set_a.remove(item_a)
    
    As you can see, if there are multiple items in set_b for which the condition evaluates to True, set_a.remove(item_a) will run twice, which will cause KeyError for second time onwards.
    
    To solve this problem, I am checking whether the item_a is there in the set_a before removing. If it is, then remove, if it isn't then continue without removing as we have already removed it
    anmol-aidora authored Oct 12, 2024
    Configuration menu
    Copy the full SHA
    1c133d5 View commit details
    Browse the repository at this point in the history

Commits on Oct 14, 2024

  1. Configuration menu
    Copy the full SHA
    66dc1e6 View commit details
    Browse the repository at this point in the history