diff --git a/contrib/mini-projects/wordcounter.md b/contrib/mini-projects/wordcounter.md index 0dce399..0c08e2e 100644 --- a/contrib/mini-projects/wordcounter.md +++ b/contrib/mini-projects/wordcounter.md @@ -31,15 +31,16 @@ The provided code defines a Python function count_words(sentence) aimed at count Finally, it prints out the number of words in the sentence. def count_words(sentence): - # Split the sentence into words - words = sentence.split() + # Split the sentence into words + words = sentence.split() - # Count the number of words - word_count = len(words) - - return word_count + # Count the number of words + word_count = len(words) + return word_count + # Example usage: sentence = input("Enter a sentence: ") number_of_words = count_words(sentence) print("Number of words:", number_of_words) +