Skip to content

Commit a622eee

Browse files
committed
Made a couple of minor tweaks to new comprehension koans
1 parent aa3d64f commit a622eee

File tree

2 files changed

+26
-24
lines changed

2 files changed

+26
-24
lines changed

python2/koans/about_comprehension.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ def test_creating_lists_with_list_comprehensions(self):
1313

1414
comprehension = [delicacy.capitalize() for delicacy in feast]
1515

16-
#self.assertEqual(__, comprehension[0])
17-
#self.assertEqual(__, comprehension[2])
16+
self.assertEqual(__, comprehension[0])
17+
self.assertEqual(__, comprehension[2])
1818

1919
def test_filtering_lists_with_list_comprehensions(self):
2020
feast = ['spam', 'sloths', 'orangutans', 'breakfast cereals',
@@ -32,7 +32,7 @@ def test_unpacking_tuples_in_list_comprehensions(self):
3232
self.assertEqual(__, comprehension[0])
3333
self.assertEqual(__, len(comprehension[2]))
3434

35-
def test_double_list_comprehention(self):
35+
def test_double_list_comprehension(self):
3636
list_of_eggs = ['poached egg', 'fried egg']
3737
list_of_meats = ['lite spam', 'ham spam', 'fried spam']
3838

@@ -43,18 +43,19 @@ def test_double_list_comprehention(self):
4343
self.assertEqual(__, len(comprehension))
4444
self.assertEqual(__, comprehension[0])
4545

46-
def test_creating_a_set_with_set_comprehention(self):
46+
def test_creating_a_set_with_set_comprehension(self):
4747
comprehension = { x for x in 'aabbbcccc'}
4848

49-
self.assertequal(__, len(comprehension)) # remeber that set members are unique
49+
self.assertEqual(__, comprehension) # rememeber that set members are unique
5050

51-
def test_creating_a_dictionary_with_dictionary_comprehention(self):
51+
def test_creating_a_dictionary_with_dictionary_comprehension(self):
5252
dict_of_weapons = {'first': 'fear', 'second': 'surprise',
53-
'third':'ruthless efficiency', 'forth':'fanatical devotion', 'fifth': None}
53+
'third':'ruthless efficiency', 'forth':'fanatical devotion',
54+
'fifth': None}
5455

55-
dict_comprehention = { k.upper(): weapon for k, weapon in dict_of_weapons.iteritems() if weapon}
56+
dict_comprehension = { k.upper(): weapon for k, weapon in dict_of_weapons.iteritems() if weapon}
5657

57-
self.assertEqual(__, 'first' in dict_comprehention)
58-
self.assertEqual(__, 'FIRST' in dict_comprehention)
58+
self.assertEqual(__, 'first' in dict_comprehension)
59+
self.assertEqual(__, 'FIRST' in dict_comprehension)
5960
self.assertEqual(__, len(dict_of_weapons))
60-
self.assertEqual(__, len(dict_comprehention))
61+
self.assertEqual(__, len(dict_comprehension))

python3/koans/about_comprehension.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ def test_creating_lists_with_list_comprehensions(self):
1313

1414
comprehension = [delicacy.capitalize() for delicacy in feast]
1515

16-
#self.assertEqual(__, comprehension[0])
17-
#self.assertEqual(__, comprehension[2])
16+
self.assertEqual(__, comprehension[0])
17+
self.assertEqual(__, comprehension[2])
1818

1919
def test_filtering_lists_with_list_comprehensions(self):
2020
feast = ['spam', 'sloths', 'orangutans', 'breakfast cereals',
@@ -30,31 +30,32 @@ def test_unpacking_tuples_in_list_comprehensions(self):
3030
comprehension = [ skit * number for number, skit in list_of_tuples ]
3131

3232
self.assertEqual(__, comprehension[0])
33-
self.assertEqual(__, len(comprehension[2]))
33+
self.assertEqual(__, comprehension[2])
3434

35-
def test_double_list_comprehention(self):
35+
def test_double_list_comprehension(self):
3636
list_of_eggs = ['poached egg', 'fried egg']
3737
list_of_meats = ['lite spam', 'ham spam', 'fried spam']
3838

3939

4040
comprehension = [ '{0} and {1}'.format(egg, meat) for egg in list_of_eggs for meat in list_of_meats]
4141

4242

43-
self.assertEqual(__, len(comprehension))
4443
self.assertEqual(__, comprehension[0])
44+
self.assertEqual(__, len(comprehension))
4545

46-
def test_creating_a_set_with_set_comprehention(self):
46+
def test_creating_a_set_with_set_comprehension(self):
4747
comprehension = { x for x in 'aabbbcccc'}
4848

49-
self.assertequal(__, len(comprehension)) # remeber that set members are unique
49+
self.assertEqual(__, comprehension) # remeber that set members are unique
5050

51-
def test_creating_a_dictionary_with_dictionary_comprehention(self):
51+
def test_creating_a_dictionary_with_dictionary_comprehension(self):
5252
dict_of_weapons = {'first': 'fear', 'second': 'surprise',
53-
'third':'ruthless efficiency', 'forth':'fanatical devotion', 'fifth': None}
53+
'third':'ruthless efficiency', 'forth':'fanatical devotion',
54+
'fifth': None}
5455

55-
dict_comprehention = { k.upper(): weapon for k, weapon in dict_of_weapons.iteritems() if weapon}
56+
dict_comprehension = { k.upper(): weapon for k, weapon in dict_of_weapons.items() if weapon}
5657

57-
self.assertEqual(__, 'first' in dict_comprehention)
58-
self.assertEqual(__, 'FIRST' in dict_comprehention)
58+
self.assertEqual(__, 'first' in dict_comprehension)
59+
self.assertEqual(__, 'FIRST' in dict_comprehension)
5960
self.assertEqual(__, len(dict_of_weapons))
60-
self.assertEqual(__, len(dict_comprehention))
61+
self.assertEqual(__, len(dict_comprehension))

0 commit comments

Comments
 (0)