We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3819d50 commit b17d61fCopy full SHA for b17d61f
contrib/mini-projects/wordcounter.md
@@ -31,15 +31,16 @@ The provided code defines a Python function count_words(sentence) aimed at count
31
Finally, it prints out the number of words in the sentence.
32
33
def count_words(sentence):
34
- # Split the sentence into words
35
- words = sentence.split()
+ # Split the sentence into words
+ words = sentence.split()
36
37
- # Count the number of words
38
- word_count = len(words)
39
-
40
- return word_count
+ # Count the number of words
+ word_count = len(words)
41
+ return word_count
+
42
# Example usage:
43
sentence = input("Enter a sentence: ")
44
number_of_words = count_words(sentence)
45
print("Number of words:", number_of_words)
46
0 commit comments