curriculum/challenges/english/blocks/daily-coding-challenges-python/68ee9e3066cfd4eb2328e8a4.md
Given a sentence string, return the number of words that are in the sentence.
count_words("Hello world") should return 2.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(count_words("Hello world"), 2)`)
}})
count_words("The quick brown fox jumps over the lazy dog.") should return 9.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(count_words("The quick brown fox jumps over the lazy dog."), 9)`)
}})
count_words("I like coding challenges!") should return 4.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(count_words("I like coding challenges!"), 4)`)
}})
count_words("Complete the challenge in JavaScript and Python.") should return 7.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(count_words("Complete the challenge in JavaScript and Python."), 7)`)
}})
count_words("The missing semi-colon crashed the entire internet.") should return 7.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(count_words("The missing semi-colon crashed the entire internet."), 7)`)
}})
def count_words(sentence):
return sentence
def count_words(sentence):
return len(sentence.split(' '))