Not seeing your question? It may still have been asked before – try () in the top-right of this page. Still can’t find it? Ask it below by hitting the reply button below this post ().
Other FAQs
The following are links to additional questions that our community has asked about this exercise:
This list will contain other frequently asked questions that aren’t quite as popular as the ones above.
Currently there have not been enough questions asked and answered about this exercise to populate this FAQ section.
This FAQ is built and maintained by you, the Codecademy community – help yourself and other learners like you by contributing!
Hey, I was wondering why this would not work for Remove_duplicates. Every time I press run, it loads for forever before determining that it didn’t work. I don’t need a piece of working code, I just want to know why this one doesn’t work.
def remove_duplicates(list_here):
dupe_removed_list = [ ]
for element1 in dupe_removed_list:
for element in list_here:
if element != element1:
dupe_removed_list.append(element)
return dupe_removed_list
I can’t seem to find any error codes that can help me find why this wouldn’t work if that helps.
@mtf Thanks for the explanation Roy! One more question - would this code work if I put in a temporary element (like “test”) and removed said element before returning dupe_removed_list?
That would be fudging. Better to not iterate that list in the outer loop. Try iterating in the inner loop when we know that element will point to a real value.
I tried to write my code like this,
can you please please explain why it gives me error?
I don’t get the solution of the exercise “remove_duplicates” so I would like to find another easier solution…
def remove_duplicates(numbers):
numbers.sort()
emp =
for n in numbers:
if n[0] != n[1]:
emp.append(n)
print remove_duplicates([1, 1, 2, 3])
Sorting changes the order, which may not be such a good thing. n is an element value. Are we sure it is an iterable? We could go through the lines, but I think we need those questions answered first.
That we have in-built constructors at our disposal, the goal here is not to exploit them. Instead, write an algorithm that will emulate the result. The above post does nothing to prove one’s own understanding.
Iterable objects can be traversed in both directions. From left to right, using positive indices, and from right to left, using negative indices. The index -1 refers to the first element from the right, as in the last element from the left.
Given an iterable, in this case a list, the complete range of indices is as follows:
-7 -6 -5 -4 -3 -2 -1 # from right to left
| | | | | | |
[ 1, 2, 3, 4, 5, 6, 7 ]
| | | | | | |
0 1 2 3 4 5 6 # from left to right