-1
私はこの関数を書いています。文字列の単語数を数えますか?
# Function to count words in a string.
def word_count(string):
tokens = string.split()
n_tokens = len(tokens)
print (n_tokens)
# Test the code.
print(word_count("Hello World!"))
print(word_count("The quick brown fox jumped over the lazy dog."))
が、出力だけではなく、
2
9
戻りn_tokensではなく – pawelty
あなたが機能であなたの結果を印刷し、しかし、あなたがいないので、それはNoneを返し、それを印刷そこから何かを返す –
イブそれを修正しました。挨拶:) –