Epitaph of John Laird McCaffery (1940-1995), who is buried in the Mount Royal Cemetery in Montreal (Canada):

grafschrift

The text was written jointly by his ex-wife and his mistress. Read the first letter of each line …

Preparation

Python has a built-in function isinstance(object, data type). The function returns a Boolean value, that indicates whether the given object belongs to the given data type.

>>> value = 1
>>> type(value)
<class 'int'>
>>> isinstance(value, int)
True
>>> isinstance(value, float)
False
>>> isinstance(value, list)
False

Assignment

An acrostic is a poem or other form of writing in which the first letter, syllable or word of each line, paragraph or other recurring feature in the text spells out a word or a message. Asked:

Example

In the following example session we assume that the files in_memoriam.txt1 and maude.txt2 are in the current directory.

>>> selection('Free your body', [1])
'F'
>>> selection('Unfold your powerful wings', [5, 12])
'lo'
>>> selection('Climb up the highest mountains', [15, 6, 11])
'euh'
>>> selection('Kick your feet up in the air', [500, 250, 10, 2]) 
'ei'

>>> acrostic('in_memoriam.txt')
'FUCKYOU'
>>> acrostic('in_memoriam.txt', 1)
'FUCKYOU'
>>> acrostic('in_memoriam.txt', positions=23)
'say'
>>> acrostic('in_memoriam.txt', positions=[4, 7, 12])
'euyoyompikutmnverheye'
>>> acrostic('maude.txt', positions=[1, 2])
'PeCuLiArAcRoStIc'