Python uses the # character to mark the beginning of a comment. The comment continues from the # character to the end of the line containing it. Python does not provide any mechanism for ending a...


Python uses the # character to mark the beginning of a comment. The comment continues from the # character to the end of the line containing it. Python does not provide any mechanism for ending a comment before the end of a line. In this exercise, you will create a program that removes all of the comments from a Python source file. Check each line in the file to determine if a # character is present. If it is then your program should remove all of the characters from the # character to the end of the line (we will ignore the situation where the comment character occurs inside of a string). Save the modified file using a new name. Both the name of the input file and the name of the output file should be read from the user. Ensure that an appropriate error message is displayed if a problem is encountered while accessing either of the files.




May 18, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here