-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathexample.py
More file actions
23 lines (19 loc) · 882 Bytes
/
example.py
File metadata and controls
23 lines (19 loc) · 882 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
PARTS = [('lay in', 'the house that Jack built.'),
('ate', 'the malt'),
('killed', 'the rat'),
('worried', 'the cat'),
('tossed', 'the dog'),
('milked', 'the cow with the crumpled horn'),
('kissed', 'the maiden all forlorn'),
('married', 'the man all tattered and torn'),
('woke', 'the priest all shaven and shorn'),
('kept', 'the rooster that crowed in the morn'),
('belonged to', 'the farmer sowing his corn'),
('', 'the horse and the hound and the horn')]
def verse(verse_num):
verse = [f'This is {PARTS[verse_num][1]}']
verse.extend(['that {0} {1}'.format(*PARTS[idx])
for idx in range(verse_num - 1, -1, -1)])
return ' '.join(verse)
def recite(start_verse, end_verse):
return [verse(verse_num) for verse_num in range(start_verse-1, end_verse)]