Files
freecodecamp--freecodecamp/curriculum/challenges/english/blocks/daily-coding-challenges-python/69c5f3d787b1725d5f00c8b8.md
T
wehub-resource-sync dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:55:53 +08:00

1.6 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
69c5f3d787b1725d5f00c8b8 Challenge 254: Odd Words 29 challenge-254

--description--

Given a string of words, return only the words with an odd number of letters.

  • Words in the given string will be separated by a single space.
  • Return the words separated by a single space.

--hints--

get_odd_words("This is a super good test") should return "a super".

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_odd_words("This is a super good test"), "a super")`)
}})

get_odd_words("one two three four") should return "one two three".

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_odd_words("one two three four"), "one two three")`)
}})

get_odd_words("banana split sundae with rainbow sprinkles on top") should return "split rainbow sprinkles top".

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_odd_words("banana split sundae with rainbow sprinkles on top"), "split rainbow sprinkles top")`)
}})

get_odd_words("The quick brown fox jumped over the lazy river") should return "The quick brown fox the river".

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_odd_words("The quick brown fox jumped over the lazy river"), "The quick brown fox the river")`)
}})

--seed--

--seed-contents--

def get_odd_words(s):

    return s

--solutions--

def get_odd_words(s):
    return ' '.join(word for word in s.split(' ') if len(word) % 2 == 1)