Pybites Logo

Split a string by spaces or quoted text

Level: Intermediate (score: 3)

Another text manipulation Bite. Code split_words_and_quoted_text that takes a text string and splits it by space, except words that are wrapped between double quotes ("), these spaces needs to be preserved.

So passing it Should give "3 words only", it would return a list of 3 (not 5) elements: ['Should', 'give', '3 words only'] (note that the double quotes are stripped off as well).

Check out the standard library, there might be a tool for the job ;) - good luck and keep calm and code in Python!