Question: python3.6 The following function, in file block.py, is supposed to take a string as argument and return a string that blocks the text in groups

python3.6

The following function, in file block.py, is supposed to take a string as argument and return a string that blocks the text in groups of 2. Eg: block(hello world) should return he ll ow or ld. Unfortunately, this function does not work as advertised. Please fix it and add types for all variables used in the function. In the comments section of your code, list the changes that you have made. def block(text):

text:string, output: string

'take text and block letters in groups of 2'

text.replace(' ', '')

btext = '

ct = 0

for letter in text:

ct += 1

if ct // 2 == 0:

btext += ' '

else:

btext += letter

return btext

def block(text): 'take text and block letters in groups of 2' text.replace(' ', '') btext = '' ct = 0 for letter in text: ct += 1 if ct // 2 == 0: btext += ' ' else: btext += letter return btext

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!