Greg Malcolm avatar Greg Malcolm committed 0d793ba

Merge github pull request #18 from boyan/master 'changed python2 and python3 about_dictionaries.py to better explain the difference between values and keys in dictionaries'

Comments (0)

Files changed (2)

python2/koans/about_dictionaries.py

         
         self.assertEqual(____, dict1 == dict2)
         
-    def test_dictionary_keys(self):
+    def test_dictionary_keys_and_values(self):
         babel_fish = {'one': 'uno', 'two': 'dos'}
         self.assertEqual(__, len(babel_fish.keys()))
-        self.assertEqual(__, 'one' in babel_fish)
-        self.assertEqual(__, 'two' in babel_fish)
+        self.assertEqual(__, len(babel_fish.values()))
+        self.assertEqual(__, 'one' in babel_fish.keys())
+        self.assertEqual(__, 'two' in babel_fish.values())
+        self.assertEqual(__, 'uno' in babel_fish.keys())
+        self.assertEqual(__, 'dos' in babel_fish.values())
         self.assertEqual(list, babel_fish.keys().__class__)
-        
-    def test_dictionary_values(self):
-        babel_fish = {'one': 'uno', 'two': 'dos'}
-        self.assertEqual(__, len(babel_fish.values()))
-        self.assertEqual(__, 'uno' in babel_fish.values())
-        self.assertEqual(__, 'dos' in babel_fish.values())
+        self.assertEqual('dict_keys', babel_fish.keys().__class__.__name__)
         self.assertEqual(list, babel_fish.values().__class__)
-        
+        self.assertEqual('dict_values', babel_fish.values().__class__.__name__)
+
     def test_making_a_dictionary_from_a_sequence_of_keys(self):
         cards = {}.fromkeys(
             ('red warrior', 'green elf', 'blue valkyrie', 'yellow dwarf',

python3/koans/about_dictionaries.py

         
         self.assertEqual(__, dict1 == dict2)
         
-    def test_dictionary_keys(self):
-        babel_fish = { 'one': 'uno', 'two': 'dos' }
+       
+    def test_dictionary_keys_and_values(self):
+        babel_fish = {'one': 'uno', 'two': 'dos'}
         self.assertEqual(__, len(babel_fish.keys()))
-        self.assertEqual(__, 'one' in babel_fish) 
-        self.assertEqual(__, 'two' in babel_fish) 
+        self.assertEqual(__, len(babel_fish.values()))
+        self.assertEqual(__, 'one' in babel_fish.keys())
+        self.assertEqual(__, 'two' in babel_fish.values())
+        self.assertEqual(__, 'uno' in babel_fish.keys())
+        self.assertEqual(__, 'dos' in babel_fish.values())
+        self.assertEqual(list, babel_fish.keys().__class__)
         self.assertEqual('dict_keys', babel_fish.keys().__class__.__name__)
-        
-    def test_dictionary_values(self):
-        babel_fish = { 'one': 'uno', 'two': 'dos' }
-        self.assertEqual(__, len(babel_fish.values()))
-        self.assertEqual(__, 'uno' in babel_fish.values())
-        self.assertEqual(__, 'dos' in babel_fish.values())
+        self.assertEqual(lis, babel_fish.values().__class__)
         self.assertEqual('dict_values', babel_fish.values().__class__.__name__)
-        
+
     def test_making_a_dictionary_from_a_sequence_of_keys(self):
         cards = {}.fromkeys(('red warrior', 'green elf', 'blue valkyrie', 'yellow dwarf', 'confused looking zebra'), 42)
         
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.