curriculum/challenges/english/blocks/daily-coding-challenges-python/699c8e045ee7cb94ed2322d4.md
Given a string of words, return a new string where each word is replaced by its length.
For example, given "hello world", return "5 5".
convert_words("hello world") should return "5 5".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(convert_words("hello world"), "5 5")`)
}})
convert_words("Thanks and happy coding") should return "6 3 5 6".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(convert_words("Thanks and happy coding"), "6 3 5 6")`)
}})
convert_words("The quick brown fox jumps over the lazy dog") should return "3 5 5 3 5 4 3 4 3".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(convert_words("The quick brown fox jumps over the lazy dog"), "3 5 5 3 5 4 3 4 3")`)
}})
convert_words("Lorem ipsum dolor sit amet consectetur adipiscing elit donec ut ligula vehicula iaculis orci vel semper nisl") should return "5 5 5 3 4 11 10 4 5 2 6 8 7 4 3 6 4".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(convert_words("Lorem ipsum dolor sit amet consectetur adipiscing elit donec ut ligula vehicula iaculis orci vel semper nisl"), "5 5 5 3 4 11 10 4 5 2 6 8 7 4 3 6 4")`)
}})
def convert_words(s):
return s
def convert_words(s):
return " ".join(str(len(word)) for word in s.split(" "))