0 of 464 solved

Count Word Frequencies in a File

Write a function `count_word_frequency(file_path)` that reads a text file and counts how many times each whitespace-separated token appears.

Treat punctuation and letter casing as part of the token exactly as written in the file.

#### Example
Input: `"sample.txt"` containing `Hello world! Hello Python Python Python`
Output: `{"Hello": 2, "world!": 1, "Python": 3}`
def count_word_frequency(file_path):
    """
    Counts the frequency of each word in a file.

    Args:
        file_path (str): The path to the input file.

    Returns:
        dict: A dictionary containing the word frequency.
    """
    # TODO: Implement the count_word_frequency function
    pass