Question: A file name is supposed to be in the form filename.ext, i.e. a name that always ended with a dot followed by a three-character extension.
A file name is supposed to be in the form filename.ext, i.e. a name that always ended with a dot followed by a three-character extension. If a filename is not following this format, it is considered as invalid. Write a function that can check whether a filename is valid or not. This function will have one input argument which is the filename (as a string). It should return a logical value as the output argument: 1 for logical true if the filename name is valid, or 0 for false if not. For example, filenames such as “data.txt”, “rain.dat”, “image.tif”, “data.dat.txt”, or “rain.fall.all.txt” is valid; whereas “movie.mpeg”, “img.tiff”, or “data” is invalid.
Step by Step Solution
There are 3 Steps involved in it
Here is an example implementation of a function in Python that checks whether a filename is valid o... View full answer
Get step-by-step solutions from verified subject matter experts
