Day9: working with dictionaries
Closed this issue · 3 comments
Hey there,
Having a hard time following instructions for day 9. Dictionaries are unsorted. So printing out the nth dictionary entry doesn't make sense to me. Since the dictionary is in alphabetical order in data.py, I assumed this means that is the "order" the instructions are referring to. So I generated a new dictionary with the index as the key.
However, the last instruction says to replace the key in the nth position of the dictionary with the value from the nth position in the list. However, that would create a duplicate key in the dictionary and doesn't work.
Please let me know if I'm completely missing something here!
Thanks very much!
-Blake
Hi Blake!
Thanks for pointing this out mate.
Firstly, correct! Dictionaries are unsorted, so the idea is to intentionally sort this dict by key and then grab the nth key/value as per the instructions. Even though data.py is "sorted" in alphabetical key order, there's no guarantee that's the order you'll get when parsing it.
As for swapping the nth dict key with the nth list value... I've been over zealous so thank you (seriously) for raising this as an issue! I'm going to strip that out of the readme for now.
We're working on an additional Bite to add in for this which should make up for my oversight.
Keeping this issue open while we work on the Bite.
Thanks again mate!
Cheers,
Julian
Hey Julian,
Thanks for the feedback. Really enjoying the course! Keep up the great work!
-Blake
Hi Blake! Check out the readme now. We've left the manual steps but have created a new Bite on the codechalleng.es platform that's a good (better) replacement.
https://codechalleng.es/bites/promo/listvsdict
Hope that helps man!
Let us know if otherwise.
Thanks!
Julian