UNC_Q10: Suggestions wrong - grader gives zero?


For question 10, the grader gives 0 even though all unit tests are passed. The only difference between expected output and my output is my suggestions {dye, days} compared to expected output which is {days, dyes}. I believe this must be a set, but Python sets are unordered. And I cannot get the elements to be the right order in the set. I tried creating a set from a sorted list, and I tried adding the wordds to suggestions in order of days, dyes. But no matter what I do, I always end up with suggestions = {dyes, days}

Is this why the grader gives it zero? And if so, how do you get suggestions to be {days, dyes}

My logic is below:

  • if the word is in vocab, use the word (alone) as suggestion list
  • If no suggestions in list (word was not in vocab), use edit_one_words as the suggestion list.
  • if still no suggestions in list (one_edit provided nothing), use edit_two_words as the suggestion list
  • if still no suggestions, use the word itself as the suggestion list

What am I doing wrong?
Thanks for any help.


Hi, @David_Simmonds

Your logic is in line with the instructions:

  • If the word is in the vocabulary, suggest the word.
  • Otherwise, if there are suggestions from edit_one_letter that are in the vocabulary, use those.
  • Otherwise, if there are suggestions from edit_two_letters that are in the vocabulary, use those.
  • Otherwise, suggest the input word.*

It is most likely that you have some implementation bug. Please message me your copy of the assignment and I will try to help you.

Hello @arvyzukai,

I have sent the file in a private message. Thanks!


Hi @David_Simmonds

You have incorrect implementation for UNQ_C9. Make sure your output matches the “Expected Output” because correct implementation of edit_two_letters is crucial for Exercise 10 get_corrections function.


Hi @arvyzukai

To my eye, the expected outputs seem to match exactly. Please let me know if I am missing something.


I am also having issue with # UNQ_C10 GRADED FUNCTION: get_corrections.
My logic is similar to the previous discussions. But still getting 0 in Grader.

Hi @David_Simmonds ,
Can you explain what you did in UNQ 9.

Can you explain the logic you used in UNQ 9.


I computed suggestions as a set which is the intersection of two sets - vocab with the word itself, with list from EOL, with list from ETL function. If all fails I use set with the word itself (that’s 4 possibilities - all but 4th are intersections). Then I tacked on the probabilty a a value to with each word as key before adding to a dictionary. Then I used a counter, finally I ranked the most common words among them. Hope this helps. I don’t want to go against the honor code.

Two areas I think the error can be. Are you dealing with the allow_switches properly. If allow_switches is true only then you should use switch_letter.

Otherwise if this is correct, check word is not empty string “” after using EOL and apply ETL on all words obtained from using EOL except this empty string. If problem persists send only that block of code (UNQ9) as a message to me by clicking on my name.