Project Overview 💡
In this project, you'll learn how to use regular expressions and file handling in Python to extract the first sentence from every .txt file in a directory. This is especially useful for summarizing or previewing content across multiple documents.
Challenge Yourself! 🚀
Before checking the solution, try writing the program on your own. It’s always a great exercise even if you don’t get it right.
Task:
Write a Python program that:
Loops through all
.txt
files in a folder
(You can use these text files and place them in a folder)Reads the content of each file
Extracts and prints the first sentence using regular expressions
Expected Output: The program should print the first sentence found in each text file to the terminal. Below we have highlighted each sentence printed out in the terminal:
Give it a shot! Scroll down when you're ready for the step-by-step guide.