Logical Text File Handling Questions
Logical Text File Handling Questions
Reverse the order of words in each line of a text file while keeping the lines in the same order.
Find and print the longest word in the entire file and the line number it appears on.
Remove duplicate lines from a text file, keeping only the first occurrence.
Print line numbers of all consecutive line pairs where the second line is the reverse of the first.
6. Paragraph Count:
Count how many paragraphs are there, assuming a paragraph is separated by one or more blank
lines.
7. Word Ladder:
Detect sequences of words where each word differs by exactly one letter.
8. Palindromic Words:
Replace every digit (09) in the file with its word form (e.g., 1 one).
Print all lines from the file that contain balanced round, square, and curly brackets.
Print all sets of three or more consecutive words in a line that start with the same letter.
Find and print the line that appears the most times in the file and how many times.
Find a given word and print the word that appears before and after it in the line (if any).
Count how many complete sentences there are. A sentence ends with `.`, `!`, or `?`.
Reverse the entire content of the file (character by character), not just by line or word.
Clean each line so that theres only one space between words, and no spaces at the start or end.
Print lines that are full palindromes (the whole line reads the same forward and backward).