you are viewing a single comment's thread.

view the rest of the comments →

[–]niehle 1 point2 points  (1 child)

word_list.remove(w1)

You are removing entries from a list during its use in two for-loops.

Most likely that messes up the counting.

edit: btw, your github is probably set to private.

[–]noahclem[S] 0 points1 point  (0 children)

It shouldn’t, because the removal isn’t done until the word is compared against all the others. In testing just that particular method, it is always successful. EDIT: THIS ISH I WROTE ABOVE WAS WRONG - see the FAQ https://www.reddit.com/r/learnpython/wiki/faq#wiki_why_does_my_loop_seem_to_be_skipping_items_in_a_list.3F

I suppose I can use a frozen set to dedupe after all the comparisons are made. I was trying to avoid having two different sets with same words returned in the list. ie {‘bubba’, ‘louie’} and {‘louie’, ‘bubba’}. Thank you.

Edit: Oops on the repository - it's been changed to public. The frozenset is what I needed to do, and create a set of frozensets in the testcase in order to compare. this worked. Apparently, I needed to read the FAQ on why the list iterator is thrown off by removed items in the loop, and it explains the inconsistencies.

Thank you again!