Home /
Expert Answers /
Computer Science /
using-a-for-and-while-loop-instead-of-try-with-roblem-specification-create-2-files-as-given-in-th-pa560
(Solved): Using a for and while loop instead of try with roblem Specification - Create 2 files as given in th ...
Using a for and while loop instead of try with
roblem Specification - Create 2 files as given in the examples below, to test you program. - Create two flies with the contents shown in the sample input flios below (data1.bt and data2 brt) - To create the files, use the text editor and copy.paste below contents into the respective files. - Include the following intormation as comments at the top of your program (file name, your name, today's date, short description of the program) - Read (from the keyboard) the name of the file to be processed (process datef bet first and then dafa2. txt ) - Read the contents of the tle using the read method and print the contents. - Close the file - Reopen the file Consider using an if statement to check the file name and decide which locp type to use. Use the ratrip method to match the output. - Ensure there's a main function and that no giobal variables are used. Sample file data1.txt This is a data fle When you process your date file remember to strip the end of the ine character. rstrip methed is a string method that strips a character from end of the string Anet = ine t satrip( (m) To handie any potentiar error use tryexcepteise Sample fle data2.txt first second third forth and fitth