avatar Bite 305. Split once, delimit many

Write a function that accepts a string and splits the text on the specified separators, but only on the first occurrence of the delimiter.

For example:

>>> split_once('abc: def: ijk, lmno: pqr - stu, wxy', separators=',-:')
['abc', ' def: ijk', ' lmno: pqr ', ' stu, wxy']

The separators parameter defaults to None if not supplied, in this case you should split on whitespace.

Login and get coding
go back Intermediate level
Bitecoin 3X

21 out of 28 users completed this Bite.
Will you be Pythonista #22 to crack this Bite?
Resolution time: ~47 min. (avg. submissions of 5-240 min.)
Pythonistas rate this Bite 5.0 on a 1-10 difficulty scale.
» Up for a challenge? 💪

We use Python 3.8