Remove Duplicates


def remove_duplicates(same):
n = []
for i in same:
if i == i:
return n
it gives this error please help
Your remove_duplicates modifies the list that was passed to it. [4, 5, 5, 4] was modified to [5, 4]. Perhaps you should make a copy first!


It looks like the assignment wants you to NOT modify the original list. So you would need to duplicate the original list and then modify that one, or create a new list and let your function only add numbers to that new list that aren’t already in that list.

“Do not modify the list you take as input! Instead, return a new list.”

Please next time you have questions about a assignment also post the link to that assignment in your post. Now I had to look it up all by myself.


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