kopia lustrzana https://github.com/animator/learn-python
Updated indentation of the python code
rodzic
5acac6257e
commit
dc3e5b80be
|
@ -30,7 +30,7 @@ The provided code defines a Python function count_words(sentence) aimed at count
|
||||||
It then calls the count_words function, passing the user's input as an argument, and stores the returned word count in the variable number_of_words.
|
It then calls the count_words function, passing the user's input as an argument, and stores the returned word count in the variable number_of_words.
|
||||||
Finally, it prints out the number of words in the sentence.
|
Finally, it prints out the number of words in the sentence.
|
||||||
|
|
||||||
def count_words(sentence):
|
def count_words(sentence):
|
||||||
# Split the sentence into words
|
# Split the sentence into words
|
||||||
words = sentence.split()
|
words = sentence.split()
|
||||||
|
|
||||||
|
@ -39,8 +39,8 @@ The provided code defines a Python function count_words(sentence) aimed at count
|
||||||
|
|
||||||
return word_count
|
return word_count
|
||||||
|
|
||||||
# Example usage:
|
# Example usage:
|
||||||
sentence = input("Enter a sentence: ")
|
sentence = input("Enter a sentence: ")
|
||||||
number_of_words = count_words(sentence)
|
number_of_words = count_words(sentence)
|
||||||
print("Number of words:", number_of_words)
|
print("Number of words:", number_of_words)
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue