# FAQ: Code Challenge: Dictionaries - Unique Values

This community-built FAQ covers the “Unique Values” exercise from the lesson “Code Challenge: Dictionaries”.

Paths and Courses
This exercise can be found in the following Codecademy content:

## Join the Discussion. Help a fellow learner on their journey.

Agree with a comment or answer? Like () to up-vote the contribution!

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

5 posts were split to a new topic: Solution Sharing

2 posts were split to a new topic: Why must an empty list be created?

I am so proud of myself, thank you codecademy, I did it and I can do that.
So my working example:

``````def unique_values(my_dictionary):
seen_values = []
for value in my_dictionary.values():
if value in seen_values:
continue
else:
seen_values.append(value)
return len(seen_values)
``````
``````def unique_values(my_dictionary):
seen_values = []
for value in my_dictionary.values():
if value == seen_values:
continue
else:
seen_values.append(value)
return len(seen_values)
``````

tryna understand why this isn’t working, it seems logical to me.

nevermind, i see what i did wrong.

``````def unique_values(my_dictionary):

return len(set(my_dictionary.values()))
``````

The hint given for this challenge isn’t entirely correct or at least misses out a step.
I did the following which returned the correct output:

def unique_values(my_dictionary):
seen_values =
counter = 0
for value in my_dictionary.values():
if value in seen_values:
continue
if value not in seen_values:
seen_values.append(value)
counter += 1
return counter

As you can see I added in a counter and returned the counter instead of seen_values which gave the correct answer for this challenge.

Welcome to the forums!

The hint is correct for this challenge. In fact, it isn’t necessary to use a counter to solve this challenge. Take a look at this snippet of your code.

What you are doing here is you are appending each `value` to `seen_values` if it is not already in `seen_values`. Then, you are incrementing the counter by 1.

Take the following argument: `[0, 0, 4, 2, 9, 9]`. After your code executes, `counter` will have a value of `4`, since it will increment by one for iterations where `0` (the first time), `4`, `2`, and `9` (the first time) are the value of `value`. However, these same values will also be appended to `seen_values`, meaning the length of `seen_values` (`4`) is the same as the value of `counter` (also `4`).

In sum, each time you increment `counter` by 1, you are also appending an element to `seen_values`, making `len(seen_values) == counter`.

1 Like