From b17d61f5a062f0e19bcb164a333580b6ba521e95 Mon Sep 17 00:00:00 2001 From: Arpna <100352419+Arpcoder@users.noreply.github.com> Date: Fri, 17 May 2024 08:35:09 +0530 Subject: [PATCH] Corrected the formatting of code --- contrib/mini-projects/wordcounter.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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) +