Python 13.13 : Exercise : Extracting extensions
Python is a powerful programming language that is widely used for a variety of applications. One of the most useful features of Python is its ability to extract information from different types of files. In this exercise, we will focus on extracting file extensions from a list of filenames.
To begin, we will create a list of filenames that we want to extract the extensions from. We will then use Python's built-in string methods to extract the extensions from each filename. The string method we will use is "split," which allows us to split a string into a list based on a specified delimiter. In this case, we will use the period (".") as the delimiter to split the filenames into a list of two parts: the filename and the extension.
Once we have extracted the extensions, we will create a new list that contains only the extensions. We will use a for loop to iterate through the original list of filenames and append the extracted extensions to the new list.
Finally, we will print out the list of extensions to verify that we have successfully extracted them. This exercise is a great way to practice using Python's string methods and for loops, and it is a useful skill to have when working with different types of files.