def count_word_occurrences(input_string):
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: ")
result = count_word_occurrences(input_string)
print("\nWord occurrences:")
for word, count in result.items():
print(f"{word}: {count}")
#source code --> clcoding.com
0 Comments:
Post a Comment