← Back to challenges

Words to Sentence

PythonHardarraysalgorithmsstringsformatting

Instructions

Create a function that turns a list of words into a comma separated list, where the last word is separated by the word "and".

Examples

words_to_sentence(["innokodakademija"]) ➞ "innokodakademija"

words_to_sentence(["Hello", "", "Bye"]) ➞ "Hello and Bye"

words_to_sentence(["Hello", "Bye", "See you soon"]) ➞ "Hello, Bye and See you soon"

Notes

None values, empty lists or lists with only empty or None values should return an empty string: ""

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.