- Reads data from a text file called sentences.txt, where each line contains a sentence. The format of the file is:
Python is fun
Radar is a palindrome
The quick brown fox jumps over the lazy dog
A man a plan a canal Panama
-
Processes each sentence to:
- Count the number of words in each sentence.
- Identify the longest word in each sentence.
- Check if any word in the sentence is a palindrome (a word that reads the same backward and forward).
-
Writes the results to a new file called sentence_analysis.txt with the following format:
Sentence: Python is fun
Word Count: 3
Longest Word: Python
Palindromes: None
Sentence: Radar is a palindrome
Word Count: 4
Longest Word: palindrome
Palindromes: Radar