barbarer / py4e-int

Python for Everybody - Interactive
GNU General Public License v3.0
4 stars 48 forks source link

https://github.com/barbarer/py4e-int/blob/master/_sources/tuples/dictionariesandtuples.rst #127

Closed DebMDuke closed 2 years ago

DebMDuke commented 2 years ago

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.")

barbarer commented 2 years ago

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.