kopia lustrzana https://github.com/animator/learn-python
Corrected the formatting of code
rodzic
3819d50869
commit
b17d61f5a0
|
@ -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)
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue