← Back to challenges

Get Word Count

PythonHardstringsmathnumbers

Instructions

Create a function that takes a string and returns the word count. The string will be a sentence.

Examples

count_words("Just an example here move along") ➞ 6

count_words("This is a test") ➞ 4

count_words("What an easy task, right") ➞ 5

Notes

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: What's Hiding Amongst the Crowd?