Question: Please answer in Python (no imports, no list comprehensions) (PART ONE) Given a file with an encoded message, parse through it line by line and

Please answer in Python (no imports, no list comprehensions)

(PART ONE)

Given a file with an encoded message, parse through it line by line and return a decoded version of the file in one string, with each decoded message in a new line. Dont remove the extra empty line (last line) from the output string.

while decoding, ignore: all exclamation points (!), question marks (?), semicolons (;), dollar signs ($) and any whitespaces.

For example:

if input = "2!03!!!4 $el!;k?in ??s!tre!$$et" ; output = "2034 elkin street"

def decode(file): """ >>> print(decode('files/encoded_1.txt').strip()) stevie wonder 2 #4 b#l3o()% m@^^^& ave Ffsdf812*2&@&#*1 Lafayette Street 32'1 fulleH##r "dr^i~v@e @&*(@@&&&@#& 8/09 1-2 >>> print(decode('files/encoded_2.txt').strip()) """

(PART TWO)

Write another function that works just like the function above but also takes an additional parameter skip (as a positive integer) that will tell you how many lines to skip through as you parse through the file. Return the string containing the actual required information.

(example): if input has 6 lines and skip = 1, output will keep line 1, skip line 2, keep line 3, skip line 4, etc. If skip = 2 then output will keep line 1, skip lines 2 and 3, keep line 4, etc.

"""

>>> print(decode_and_skip('files/encoded_1.txt').strip()) stevie wonder Lafayette Street 8/09 1-2 >>> print(decode_and_skip('files/encoded_2.txt').strip()) """

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!