def count_word_frequency(input_string):
"""
Counts the frequency of each word in the input string.
Args:
input_string (str): The input string.
Returns:
dict: A dictionary with words as keys and their frequencies as values.
"""
words = input_string.split()
word_count = {}
for word in words:
word = word.lower()
if word in word_count:
word_count[word] += 1
else:
word_count[word] = 1
return word_count
input_string = input("Enter a string: ")
word_frequency = count_word_frequency(input_string)
print("\nWord Frequency:")
for word, count in word_frequency.items():
print(f"'{word}': {count}")
#source code --> clcoding.com
0 Comments:
Post a Comment