Code works in Python2 and Python3 but throws and error in Code Academy?


def remove_duplicates(dups):
    nodups = []
    end = len(dups)-1
    sortdups = list(dups)
    for i in range(0,end):
        if sortdups[i] != sortdups[i+1]:
    return nodups


the editor is not recognizing spaces, must be a hidden character issue, I will re-type the program.


Is there a reason this line repeats?


Sorry for any confusion, the editor dropped all of my indents.
The statement just before the return insures that the last data item is included on the output.


Are you getting the correct output, or not? If not, then there is your culprit.


The error message in question seems like relevant information, don't you think?

I'm guessing that it's telling you what failed and what the input was.
I'm also guessing that you didn't try the failing input when you ran the code yourself.

So your own testing doesn't cover the case that codecademy finds a problem with.
If you run no tests at all, if you don't run your code at all, then that will also have the outcome that there is no error.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.