Page: dictionariesandtuples.rst
.. activecode:: question10_4_3
The instructions are "Write code that will transform dictionary d into a list of tuples, called tup_list, sorted by the keys’ values in descending order." This page show sorting by keys not by values.
--> unit test is not sorted correctly (sorted by values, not keys)
def testOne(self):
self.assertEqual(tup_list, [('e', 30), ('c', 27), ('d', 15), ('a', 10), ('f', 3), ('b', 2)], "Checking to make sure the list was sorted correctly.")
should be
def testOne(self):
self.assertEqual(tup_list, [('f', 3), ('e', 30), ('d', 15), ('c', 27), ('b', 2), ('a', 10)], "Checking to make sure the list was sorted correctly.")
Sorry that it took me so long to notice this. You are correct. We haven't covered how to sort a list of tuples by values yet so I have changed it to be a sort of the keys in descending order.
Page: dictionariesandtuples.rst .. activecode:: question10_4_3
The instructions are "Write code that will transform dictionary d into a list of tuples, called tup_list, sorted by the keys’ values in descending order." This page show sorting by keys not by values. --> unit test is not sorted correctly (sorted by values, not keys) def testOne(self): self.assertEqual(tup_list, [('e', 30), ('c', 27), ('d', 15), ('a', 10), ('f', 3), ('b', 2)], "Checking to make sure the list was sorted correctly.") should be def testOne(self): self.assertEqual(tup_list, [('f', 3), ('e', 30), ('d', 15), ('c', 27), ('b', 2), ('a', 10)], "Checking to make sure the list was sorted correctly.")