GH avatar Bite 155. Split a string by spaces or quoted text

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!

Login and get coding
go back Intermediate level
Bitecoin 3X

Will you be Pythonista #67 to crack this Bite?
Resolution time: ~44 min. (avg. submissions of 5-240 min.)
Pythonistas rate this Bite 2.75 on a 1-10 difficulty scale.
» You can do it! 😌

We use Python 3.7