FAQ: Using Dictionaries - Get All Keys


This community-built FAQ covers the “Get All Keys” exercise from the lesson “Using Dictionaries”.

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

Computer Science

FAQs on the exercise Get All Keys

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

Ask or answer a question about this exercise by clicking reply (reply) below!

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

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

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!


Why It is not correct to do with the below code:
users = list(user_ids)

I have printed out it and it is matching with the needs.


Following the instructions, the following is the expected output for print (users)

dict_keys(['pythonGuy', 'keysmithKeith', 'lyleLoop', 'teraCoder', 'samTheJavaMaam'])

whereas your code gives the following:

['pythonGuy', 'keysmithKeith', 'lyleLoop', 'teraCoder', 'samTheJavaMaam']

is not a proper list, per se, but a dict_keys object.


maksagery , I made the same mistake, mate.

Check the following in the description:

Dictionaries also have a “ .keys() ” method that returns a “ dict_keys ” object.


Thank you for the hint mtf !

user_ids = {"teraCoder": 100019, "pythonGuy": 182921, "samTheJavaMaam": 123112, "lyleLoop": 102931, "keysmithKeith": 129384}



dict_keys(['pythonGuy', 'teraCoder', 'keysmithKeith', 'samTheJavaMaam', 'lyleLoop'])
['pythonGuy', 'teraCoder', 'keysmithKeith', 'samTheJavaMaam', 'lyleLoop']
['pythonGuy', 'teraCoder', 'keysmithKeith', 'samTheJavaMaam', 'lyleLoop']

can someone explain what the different for this code…?
i mean, which one most suitable to use or most common…?



In what way is the list sorted?
I can’t see it being sorted alphabetically or by value nor length of word.