Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please answer in Python (no imports, no list comprehensions) Given a file with an encoded message and the parameter skip (as a positive integer), parse

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

Given a file with an encoded message and the parameter skip (as a positive integer), 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. Then, skip through lines based on the 'slip' parameter that will tell you how many lines to skip through as you parse through the file. Return the string with only the required information after 'skip'.

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

(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.

examples:

Input file contents, skip = 2 process Output file contents:
j!!!!a?$;ck! $r?ea!che;;r 2!!3@4 b#l31oo%m@^ w!$ay$? FSD!@si$$%m3~on f!is#he%r! 1?2!!1 r$oc!ke!??fe?l!!l$e;r av;;e?n$$u$e!! 3;2'1 ?fu$l!!leH##r ;"?dr^i~!v@e$ @@4!:)5#0???p1m# 7?$/2!!9? 0!!6.;??4$5! line1 --> keep line2 --> skip line3 --> skip line4 --> keep line5 --> skip line6 --> slip line7 --> keep jack reacher 121 rockefeller avenue 7/29 06.45

"""

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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions